EKL New Keyword

EKL New Keyword

I wanted to show you how you could navigate the CAD Part Structure to create a New Geometrical Set and then add a New Point into the New Geometrical Set.

The first step is to get the Root UI object, which is the Part Feature

Let ioPartFeature ( PartFeature )
Set ioPartFeature = GetRootUI()


Now we have the Part Feature we can get the VPMRepreference / Shape ( I will write a blog about these objects ). Here I have changed the V_Name to show you where we are in the specification tree, see image above.

Let ioVPMRepReference ( VPMRepReference )
ioVPMRepReference = GetPLMOwner( ioPartFeature )
ioVPMRepReference.V_Name = "RepRef - V_Name"


We can now step further up the tree to VPMCoreReference / Representation. Again I have changed the V_Name, see image above.

Let ioPLMCorereference( PLMCoreReference )
ioPLMCorereference = ioVPMRepReference.AggregatingReference
ioPLMCorereference.V_Name = "CoreRef - V_Name"


We can now filter all the children below the Part Feature specifically looking for a Geometrical Set ( OpenBodyFeature ) called Points. If the list that is returned by the Filter function is empty we will create a New Geometrical Set and Append it to the list.

Let ioGeoSetList ( List )
ioGeoSetList = ioPartFeature.Children->Filter( "OpenBodyFeature" , "x.Name==\"Points\"" )

If ( ioGeoSetList ->Size() == 0 )
{
Let ioGeoSet ( OpenBodyFeature )
ioGeoSet = new("OpenBodyFeature" , "Points" , ioPartFeature )
ioGeoSetList ->Append( ioGeoSet )
}


Finally we can create a New Point in the Geometrical Set.

Let ioPoint ( Point )
ioPoint = new("Point" , "Point.1" , ioGeoSetList[ 1 ] )
ioPoint = point( 10mm , 20mm , 30mm )


Its important to know that the New function will create a New feature every time the code is executed, if a feature already exists with the same name within the container the feature is updated, so any child geometry will be preserved. Its important to understand that if you use a loop to build many points or lines or… if the loop executed many time with varying loop iterations when the loop iterations are larger than the first or a previous execution then additional New features will be created. If the loop iterations is smaller the existing features will be updated but the excess features will not be deleted, you will have to write code to delete the extraneous features. This is shown below we can see there are 10 points in the specification tree created from a previous execution. The new execution is only looping 5 times and we can see that the five points have been modified and require an update, the last five points have not been edited.

Complete Code.

/*Rule created by me 1/8/2021*/

Let ioPartFeature ( PartFeature )
Set ioPartFeature = GetRootUI()

Let ioVPMRepReference ( VPMRepReference )
ioVPMRepReference = GetPLMOwner( ioPartFeature )
ioVPMRepReference.V_Name = "RepRef - V_Name"

Let ioPLMCorereference( PLMCorereference )
ioPLMCorereference = ioVPMRepReference.AggregatingReference
ioPLMCorereference.V_Name = "CoreRef - V_Name"

Let ioGeoSetList ( List )
ioGeoSetList = ioPartFeature.Children->Filter( "OpenBodyFeature" , "x.Name==\"Points\"" )

If ( ioGeoSetList ->Size() == 0 )
{
Let ioGeoSet ( OpenBodyFeature )
ioGeoSet = new("OpenBodyFeature" , "Points" , ioPartFeature )
ioGeoSetList ->Append( ioGeoSet )
}

Let ioPoint ( Point )
ioPoint = new("Point" , "Point.1" , ioGeoSetList[ 1 ] )
ioPoint = point( 10mm , 20mm , 30mm )