AnsweredAssumed Answered

How to indentify and select region from PostIntersect2 feature to exclude it, in vba code ?

Question asked by Pawel Szczygiel on Nov 20, 2019

How to indentify and select region from PostIntersect2 feature to exclude it, in vba code ? I am trying to cut out multiple random size random distribution spheres out of solid rectangular body. The rectangular body is sometimes as region 1 sometimes at region 2. How is the feature assigning the regions ? What inputs/outputs are there in preintersect and postintersect features. I know its an array of bodies as boolean ( to exclude ) how to distinguish them one from another ?

 

I thought it was depending on the number of regions created so i did :

Dim excludeArray As Variant
Dim j As Long
Dim nbrBodies As Long
Dim bodyExcludeArray() As Boolean
Dim bodyArray As Variant
Set swFeatureMgr = swDoc.FeatureManager
Dim errors As Long
Dim warnings As Long
Dim fileName As String

 

If i = 1 Then
   boolstatus = swPart.Extension.SelectByID2(sphereName, "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)
   boolstatus = swPart.Extension.SelectByID2(blockName, "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)
Else
   boolstatus = swPart.Extension.SelectByID2(sphereName, "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)
   boolstatus = swPart.Extension.SelectByID2(interName, "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0)
End If 

 

bodyArray = swFeatureMgr.PreIntersect2(False, 2)
swDoc.ClearSelection2 True
nbrBodies = UBound(bodyArray)##

 

ReDim bodyExcludeArray(nbrBodies)

 

If nbrBodies Mod 2 = 1 Then
   For j = 0 To nbrBodies
      bodyExcludeArray(j) = True
Next
   bodyExcludeArray(1) = False
Else
   For j = 0 To nbrBodies
bodyExcludeArray(j) = True
Next
bodyExcludeArray(0) = False
End If

 

Outcomes