Creating a Knowledge Pattern to Instantiate a User Feature

You can initialize your variable before entering the for loop.

Note: To view an example, import the Bounding_Box_Destination_000.3dxml file located in win_b64\startup\Knowledgeware\3D Templates Samples\Sample1.

  1. From the Compass, click 3D Modeling Apps and select Engineering Rules Capture.
  2. From the Engineering Rules Capture section, click Knowledge Pattern .
    The Knowledge Pattern Editor opens.
  3. In the Knowledge Pattern editor, enter the following code.
    let segment(SMPSegmentonCrv)
    let i(Integer)
    
    i=1
    for i while i<= NbSegments
    {
             segment = CreateOrModifyTemplate("Catalog|SMPSegmentonCrv",Segments,`Relations\Knowledge Pattern.1\segments`, i)
             segment.Curve =Inputs\Curve.1 
             segment.Ratio1 = (i-1)/NbSegments
             segment.Ratio2 = i/NbSegments
     
              EndModifyTemplate(segment) 
    
               segment.Name = "Segment." + ToString (i)
    }
  4. Click OK to validate.