Generative Functions

This topic describes the Generative Functions.

Note: Make sure that you have the Engineering Templates reuse license to use the functions listed below. The functions CreateOrModifyTemplate, CreateOrModifyDatum and EndModifyTemplate are specific to Knowledge Patterns. They create respectively templates instance objects and datums objects.

This page discusses:

CreateOrModifyDatum

Method used to create or modify a datum (only used by the Knowledge Pattern Feature).

Signature

CreateOrModifyDatum(datumType: String, destination: Feature, patternList: List, indexInPatternList: Integer) : UndefinedType

Arguments

Name Input / Output Required? Type Comment
datumType In Yes String Indicates the datum type: Point, Line, Curve, Circle, Surface, Plane, Volume.
destination In Yes Feature Indicates the destination feature (PartBody, ...).
patternList In Yes List Indicates the pattern list.
indexInPatternList In Yes Integer Indicates the index number in the pattern list.
Note: You can handle attributes using the Type view (if the type was properly generated and referenced in the Knowledge Environment tab) or using the SetAttributeObject function.

ReturnType

UndefinedType

Example

Note: To view an example, import the Sample_extra.3dxml file located in win_b64\startup\Knowledgeware\PKT Samples\Sample 1 in the installation folder.

CreateOrModifyTemplate

Method used to instantiate a user feature. You can access and modify the inputs of this user feature by using the type attributes (xxx.input name or xxx. output name) and the published name (only used by the Knowledge Pattern Feature).

Signature

CreateOrModifyTemplate(templateId (ARM): String, destination: Feature, patternList: List, indexInPatternList: Integer) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
templateId (ARM)InYesString Indicates the name of the feature.
  • If the templates are stored in ARM table, the first part of the argument is the ARM path. The second part is the name of the user feature.
  • If the template that you want to instantiate is contained in the current document, the name of the user feature.
destinationInYesFeatureIndicates the destination feature (PartBody, ...).
patternListInYesListIndicates the pattern list.
indexInPatternListInYesIntegerIndicates the index number in the pattern list. The function usually waits for contiguous indexes from 1 to n. 0 index is accepted but has the meaning of systematically appending created object at the end of the list, so 0 index should not be used in conjunction with non null indexes. If an object is removed from the list before the end of the pattern, or is replaced by another one at its index, it is deleted at the end of the pattern execution.

ReturnType

UndefinedType

Example

In the example below, the template used is a typed user feature.

udf = CreateOrModifyTemplate("PktARMcatalog2|BoxUDF", PartBody, Boxes, i)
udf = CreateOrModifyTemplate("UserFeature1", `Geometrical Set.1` , Boxes, i)
Note: To view an example, import the Sample_extra.3dxml file located in win_b64\startup\Knowledgeware\PKT Samples\Sample 1 in the installation folder.

EndModifyTemplate

Function used to trigger the update of the instantiated Object after modifying its inputs.

Signature

EndModifyTemplate(template: Feature)

Arguments

NameInput / OutputRequired?TypeComment
templateInYesFeatureObject returned by the CreateOrModifyTemplate function. The EndModifyTemplate function can only be used together with the CreateOrModifyTemplate and the InstantiateTemplate ones.
Note: .Name attribute access does not work before you call the EndModifyTemplate function. When trying to do so, an error message appears.
Note: To view an example, import the Sample_extra.3dxml file located in win_b64\startup\Knowledgeware\PKT Samples\Sample 1 in the installation folder.

InstantiateTemplate

Function used to instantiate any type of template. This method is available in the Actions editor and in Know-how Apps Components. The input of this method is a link to a resource table that can contain any type of templates (power copies, user features and engineering templates); the second argument is the destination in the part or the product. You can value the inputs using Setattributeobject, modify the parameters values using Setattributexxx, and access the user feature outputs using GetattributeObject. After using InstantiateTemplate, you must use EndModifyTemplate .

Notes:
  • This method returns an object representing the template but which is not the template itself.
  • The expected setup data name is the internal one.
  • When instantiating a user feature using InstantiateTemplate or CreateOrModifyTemplate, the modification of the attributes works properly only if it is called after EndModifyTemplate (If it is not called after EndModifyTemplate, an error message appears.) The attributes are the following:
    • Feature: Name, Owner, UserInfoComment, PrimaryType, NamedURLs, Children.
    • Visualizable: Show, Color, Layer, Pick
    • GeometricalFeature: Activity, Error, IsRoot, IsLeaf, IsDatum
  • When used to instantiate an engineering template, the InstantiateTemplate function result can be used to get the created instances or duplicated references using the CreatedInstances and CreatedReferences attributes (see Example 3 below).
  • When instantiating an engineering template, you can set inputs that are out of the destination context indicated in the InstantiateTemplate function using the RootContext attribute. This attribute can be set on the instantiation object to specify a common root between the instantiation destination and the components containing the inputs.
  • When instantiating an engineering template, you can get a handle on the objects created by the template, especially in a multi-root context. The CreatedInstances and CreatedReferences attributes are available on the instantiation object to retrieve the objects created by the template.

Signature

InstantiateTemplate(templateId (ARM): String, destination: Feature) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
templateId (ARM)InYesString-
destinationInYesFeature-

ReturnType

UndefinedType

Example 1

let S(Surface)
let temp (Feature)
temp= InstantiateTemplate ("ARM", destination)
temp.SetAttributeObject("Input",...)
temp.SetAttributeObject("Input",...)
EndModifyTemplate(temp)

Example 2

myTemplate = CreateOrModifyTemplate(...)
myTemplate.PointA = x
myTemplate.PointB = y
myTemplate.Radius = z
EndModifyTemplate(myTemplate)
myTemplate.Name = "MyTemplateInstance"

Example 3

let tmp(Feature)
let listOfInstances(List)
let ListOfReferences(List)
tmp = InstantiateTemplate("MyPLMTemplate”,destination)
[…]
EndModifyTemplate(tmp) /* End of PLM Template Instantiation */
listOfInstances = tmp->GetAttributeObject("CreatedInstances")
listOfReferences = tmp->GetAttributeObject("CreatedReferences")

IsPatternInstanceLocked

Method used to specify if an instance is locked (only used by the Knowledge Pattern Feature).

Signature

IsPatternInstanceLocked(patternInstance: Feature) : Boolean

Arguments

NameInput / OutputRequired?TypeComment
patternInstanceInYesFeatureIf the answer is true, the instance is locked. If the answer is false, the instance is not locked.

ReturnType

Boolean

LockPatternInstance

Method used to lock the instance instantiated by the CreateOrModifyTemplate or CreateOrModifyDatum functions hence avoiding the modification of this instance. A new affectation or an attribute modification does not modify the instance (only used by the Knowledge Pattern Feature).

Signature

LockPatternInstance(patternInstance: Feature, doLock: Boolean)

Arguments

NameInput / OutputRequired?TypeComment
patternInstanceInYesFeatureIndicates the pattern.
doLockInYesBooleanIf set to true, the instance is locked. If set to false, the instance is not locked.

ReplaceInstance

Lets you replace an instance by another one when editing a structure.

Signature

ReplaceInstance(iToReplace : PLMEntity, iReplacingRef : PLMEntity) : PLMEntity

Arguments

NameInput / OutputRequired?TypeComment
iToReplaceInYesPLMEntityTakes an instance (iToReplace) and replaces it with an instance of iReplacingRef which is a Reference. The returned object is the created instance. ReplaceInstance should reroute all possible links from the original instance to the replacing one, especially links that can be easily resolved such as links on publications (if the original publications match the replacing ones in terms of name and type).
Note: Replacing instances was already possible by using ManageInstance. But ManageInstance relies on an ARM/PRM path where ReplaceInstance works with any instance available in session. The equivalent functionality is available interactively by using the Replace menu.
iReplacingRefInYesPLMEntity

ReturnType

PLMEntity

PLMEntity.CreateConstraint()

Method used to create a constraint for a given product.

Note: To view an example, import the CreateCabinFromExcelFile.3dxml file located in win_b64\startup\Knowledgeware\EKL Samples\Sample2 in the installation folder.

Signature

PLMEntity.CreateConstraint(destination: PLMEntity, name: String, type: String [, element: ObjectType, ..]) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
destinationInYesPLMEntity-
nameInYesStringIndicates the name of the created constraint. If a constraint with the same name already exists, it is replaced by the new one. If the constraint name is missing, the default constraint name is used instead.
typeInYesString Indicates the Assembly Constraint type. For example, an angle.
elementInNoObjectType
  • The object on which the constraint is created. It is retrieved using a path string created using the CreatePathString method.
  • In the context of Know-how apps, the object passed can be a KWEpointer.
Note: List of available constraints:
Input TypeReturned Object TypeValid Inputs Types
Angle MRXAngleLine, Line
Line, Plane
Plane, Plane
HingeMRXHingePlane, Plane, Line
CoincidenceMRXCoincidenceLine, Line
Line, Plane
Plane, Plane
Point, Cone
Point, Curve
Point, Cylinder
Point, Line
Point, Plane
Point, Point
Point, Sphere
Point, Surface
ContactMRXContactCircle, Cone
Circle, Sphere
Cone, Cone
Cylinder, Cylinder
Plane, Cylinder
Plane, Plane
Plane, Sphere
Sphere, Cone
Sphere, Sphere
DistanceMRXDistanceLine, Line
Line, Plane
Plane, Plane
Point, Line
Point, Plane
Point, Point
FixMRXFixAxisSystem
VPMInstance
FixTransfoMRXFixTransfoAxisSystem
VPMInstance
FixTogetherMRXFixTogetherAxisSystem, AxisSystem
VPMInstance, AxisSystem
VPMInstance, VPMInstance
FixTogetherTransfoMRXFixTogetherTransfoAxisSystem, AxisSystem
VPMInstance, AxisSystem
VPMInstance, VPMInstance
LengthMRXLengthPoint, Curve
ParallelismPRXParallelismLine, Line
Line, Plane
Plane, Plane
PerpendicularityMRXPerpendicularityLine, Line
Line, Plane
Plane, Plane
ProjectionMRXProjectionAxisSystem, Surface, Point
RollMRXRollCurve, Curve
SlideMRXSlideCurve, Curve
SymmetryMRXSymmetryVPMInstance, VPMInstance, Plane
Line, Line, Plane
Plane, Plane, Plane
Point, Point, Plane
TangencyMRXTangencyPlane, Surface

ReturnType

UndefinedType

PLMEntity.CreatePublication()

Method used to publish either an object or a publication for a given product.

Signature

PLMEntity.CreatePublication(destination: PLMEntity, instance: VPMInstance, published element: ObjectType, name: String) : String

Arguments

NameInput / OutputRequired?TypeComment
destinationInYesPLMEntity Indicates the product to which the created publications belongs
instanceInYesVPMInstance Indicates the product instance to which the published element belongs
published elementInYesObjectType-
nameInYesStringIndicates the name of the new Publication (if a publication with the same name exists, it is replaced by the new one and if the publication name is missing, the pointed element name is used instead)

ReturnType

String

Example

product1.1 -> createpublication(product1.1\part2.1,part2\partbody\
plane.2,"plane")

PLMEntity.DeletePublication()

Signature

PLMEntity.DeletePublication(publisher: PLMEntity, pubname: String)

Arguments

NameInput / OutputRequired?TypeComment
publisherInYesPLMEntity-
pubnameInYesString-

PLMEntity.ListPublications()

Lets you get the list of publications created on the object on which it is called. The list contains strings that correspond to the publication names.

Signature

PLMEntity.ListPublications() : List

ReturnType

List

Example

  1. Create a knowledge action and make "iPrd : VPMReference" an input of this action.
  2. Enter the following script:
    Let lPubs(List)
    lPubs = iPrd->ListPublications()
    if lPubs.Size() == 1 AND lPubs[1] == "MyPoint"
    {
    	iPrd->CreatePublication(NULL,iPrd->Find("Point","x.Name==\"MyPoint2\"",TRUE), "PubCreatedDuringTheAction")
    	lPubs = iPrd->ListPublications()
    	if lPubs.Size() == 2
    	{
    		Message("OK")
    	}
    }
    
  3. Execute the action on the product containing the publication.
  4. Check that it displays "OK" and that a new publication was created under the product.

PLMEntity.CreatePathString()

Method used to identify an object in the tree in the form of a string starting with the root of the path and ending with the final element (an object or a publication) for a given assembly.

Note: The result of this method can be used in the following functions or methods:
  • CreateConstraint
  • Access
  • SetMaterialCore
  • CenterGraph
  • AddToSelection

Signature

PLMEntity.CreatePathString(root: PLMEntity, instance: VPMInstance, element: ObjectType) : String

Arguments

NameInput / OutputRequired?TypeComment
rootInYesPLMEntity Indicates the beginning (root) of the path.
instanceInYesVPMInstanceIndicates the product instance to go through to reach the final element of the path.
elementInYesObjectTypeIndicates the final element of the path (this particular element can be either an Object or a Publication Name)

ReturnType

String

Example 1



CreatePathString(I.2, P1)
which corresponds to the following path: I.2/ShapeProd.1/PartBody/P1.

Example 2

pathPubPlane=Root -> CreatePathString(Product1.1, "Plane")

PLMEntity.ManageInstance()

Method used to return the created or replaced product instance. The Product or Part reference document has to be either directly linked by an ARM table description or a part family element.

PLMEntity.ManageInstance(product: PLMEntity, resource (catalog, chapter, product, 3D Shape): String, queryExpression: String, instanceName: String) : PLMEntity

Arguments

NameInput / OutputRequired?TypeComment
productInYesPLMEntity-
resource (catalog, chapter, product, 3D Shape)InYesString

Note: chapterName is not needed anymore because resource tables can directly reference catalog chapters.

queryExpressionInYesStringFilter allowing to obtain one element to instantiate it. Its behavior depends on what is referenced in the resources table:
  • A product reference: the product is instantiated. The queryExpression is useless and not used in this case.
  • A 3D shape representation: the 3D shape is instantiated. The queryExpression is useless and not used in this case.
  • A catalog or a chapter: the queryExpression is used to filter the catalog or chapter. It has to return only one catalog item (otherwise, an evaluation error is raised). This item has to refer either a product reference or a 3D shape representation or a component family item. In those cases, the object is instantiated.

instanceNameInYesStringThe ManageInstance method either creates or replaces a product instance. This argument is used to retrieve the instance, if any. It is also used to rename the created instance.

ReturnType

PLMEntity

Example 1

let newInstance (Product)
...
/* Creates or replaces the instance under Product1 of name "Instance of MyPart" 
This instance is the instance of the part pointed by the catalog description MyPart 
in the catalog ARM. */
newInstance = Product1  -> ManageInstance("MyPart", "","", "Instance of MyPart)

Example 2

let newInstance (Product)
...
/* Creates or replaces the instance under Product1 of name "Instance of Bolt part family item"
This instance is a part family instance, found in family ISO_4014_GRADES_A_B_HEXAGON_HEAD_BOLT in the
catalog pointed by the resource name in the resource table */
set newInstance = Product1  -> ManageInstance("Bolt","ISO_4014_GRADES_A_B_HEXAGON_HEAD_BOLT", "PartNumber == 
\"ISO 4014 BOLT M2x16 STEEL GRADE A 
HEXAGON HEAD\"","Instance of Bolt part family item")

Note: Remember that in this case that \" is used to specify a string within a string.

PLMEntity.RemoveInstance()

Method used to return the name of the product instance to remove.

Signature

PLMEntity.RemoveInstance(product: PLMEntity, instanceName: String) : PLMEntity

Arguments

NameInput / OutputRequired?TypeComment
productInYesPLMEntity-
instanceNameInYesString-

ReturnType

PLMEntity

Example

product1.removeinstance("instance of MyPart")

The example above shows how to remove the instance created in the above example 1 to illustrate the manageInstance function.

VPMInstance.CreateContextualConstraint()

Method used to create a contextual constraint that is to say you can create a constraint in a Product which references data located outside this Product.

Signature

VPMInstance.CreateContextualConstraint(destination: VPMInstance, context: PLMEntity, name: String, type: String [, element: ObjectType, ..]) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
destinationInYesVPMInstance-
contextInYesPLMEntity-
nameInYesString-
typeInYesString-
elementInNoObjectType-


This constraint is not contextual, it is created at Instance1 level and only references the items located below Instance1.


This constraint is a contextual one, it is created below SubInstance2 and references external items contained in SubInstance1.

ReturnType

UndefinedType

Important:
  • The first argument, the context, must be an instance that contain all the instances referenced by the constraint (see picture 2).
  • The paths indicated must start at the instance context.