Instantiating User Features Using a Knowledge Pattern

You can instantiate user features using the knowledge pattern. Note that the generated data must be saved in separate bodies.

This task shows you how to:


Before you begin: You must have created the User Feature. Import and open the Bounding_Box_Destination_000.3dxml file located in win_b64\startup\Knowledgeware\3D Templates Samples\Sample1.

Create the Resource Table

You must first create a resource table that contains the user feature.

  1. From the Compass, click 3D Modeling Apps and select Engineering Rules Capture.
  2. Click Resource Table .
    The Resource table management window opens.
  3. Click Add a new resource item .
    A row is added to the table.
  4. Double-click the Logical Name box and enter UDFBoundingBox.
  5. Double-click the Resource Type cell to display the scrolling list and select User Defined Feature.
    A row is added to the table.
  6. Select the resource row and double-click the Unset resource cell to allocate the resource.
    The Select a User Defined Feature for item 'Resource1' dialog box appears.
  7. Type the name of the resource and click Search.
  8. Select the resource from the list and click OK twice.
    The resource is assigned and the resource table is created.

Create the Knowledge Pattern

You must now create the knowledge pattern to instantiate the user features.

  1. From the Compass, click 3D Modeling Apps and select Engineering Rules Capture.
  2. Click Knowledge Pattern
    The Knowledge Pattern Editor opens.
  3. In the Knowledge Pattern Lists frame, enter BoundingBoxes into the Name box and click Add.
  4. Enter the following knowledge pattern body. In our example, enter the following script:
    // We query all objects of type 'Surface' in the Geometrical Set 'Surfaces'
    let surfaces (List)
    surfaces = Inputs.Query("Surface","")
    
    let basePlane (Plane) // Will be used to filter planes
    let udf (UserFeature) // User Feature instance
    let currentSurface (surface) 
    
    // Main loop used to instantiate User Features
    let i, k (Integer)
    i = 1           // used for the loop
    k = 1          // used to increment instantiated User Features
    for i while i <= surfaces->Size() 
    {
    	// If the current surface is not a plane, we instantiate the user Feature
    	// Indeed, a plane is considered as a Surface, but it is an infinite surface, so we don't want to create a bounding box around it
    	set basePlane = surfaces[i]
    	if basePlane == NULL 
    	{	
    		        // basePlane == NULL which means that the current feature is a surface, but not a plane. Thus, we can create the associated bounding box.
    		
    		        // Beginning of instantiation
    		        set udf = CreateOrModifyTemplate("UDFBoundingBox", Destination , Relations\KPCreateBoundingBoxes\BoundingBoxes, k)
    		
    	        	// Input selection
    	        	udf->SetAttributeObject("Surface", surfaces[i])
    		
    	         	// End of instantiation
    	         	EndModifyTemplate(udf)
    		
    	         	udf.Name="BoundingBoxOfSurface"+i  // User Feature instance name
    	          k = k + 1                          // We increment counter
    	}	
    }
    Note: When the attribute contains a point or a space for example, the syntax is the following: Udf."Point.1".
  5. Click OK when done.

The knowledge pattern is created.

Execute the Pattern

You are going to instantiate the user feature using the knowledge pattern.

Right-click the knowledge pattern in the tree and select Knowledge Pattern_name object > Execute.
The user features are instantiated. In our example, the bounding boxes are inserted.