Hi,
I want to collect bodies from each component group individually to create wrap geometry, But this is collecting all the bodies in the workpart. Is there anyway to change it only the component from group.
'Collect all Component group detail and Template coordinate system details
Dim GroupList As List(Of ComponentGroup) = New List(Of ComponentGroup)
Dim BodyList As List(Of Body) = New List(Of Body)
Dim PartsList As List(Of Part) = New List(Of Part)
For Each Mygroup As ComponentGroup In workPart.ComponentGroups
If TypeOf Mygroup Is ComponentGroup Then
GroupList.Add(Mygroup)
End If
Next
For Each MyG As ComponentGroup In GroupList
For Each Mycomp As Component In MyG.GetComponents
PartsList.Add(Mycomp.OwningPart)
Next
For Each MyP As Part In PartsList
For Each MyB As Body In AskAllBodies(MyP).ToArray
BodyList.Add(MyB)
Next
Next
lw.WriteLine("Count: " & BodyList.Count.ToString)
'Create Wrap gemotry with bodyList and move to next group
Dim nullFeatures_WrapGeometry As WrapGeometry = Nothing
Dim WrapBuild As Features.WrapGeometryBuilder
WrapBuild = workPart.Features.CreateWrapGeometryBuilder(nullFeatures_WrapGeometry)
WrapBuild.CloseGaps = Features.WrapGeometryBuilder.CloseGapType.NoOffset
WrapBuild.AddOffset.RightHandSide = "0"
WrapBuild.SplitOffset.RightHandSide = "0"
WrapBuild.IsInterpart = True
WrapBuild.DistTol = 0.01
WrapBuild.Associative = False
Dim AddBodies As Boolean = Nothing
AddBodies = WrapBuild.Geometry.Add(BodyList.ToArray)
WrapBuild.PlanesList.Clear(ObjectList.DeleteOption.NoDelete)
Dim NxObj As NXObject
NxObj = WrapBuild.Commit()
Dim MyBrep As Brep = Utilities.NXObjectManager.Get(NxObj.Tag)
MyBrep.SetName("Group_" & MyG.Name)
Dim HideObj() As DisplayableObject = Nothing
HideObj = MyBrep.GetBodies()
theSession.DisplayManager.BlankObjects(HideObj)
workPart.ModelingViews.WorkView.FitAfterShowOrHide(NXOpen.View.ShowOrHideType.HideOnly)
WrapBuild.Destroy()
Next
Function AskAllBodies(ByVal thePart As Part) As List(Of Body)
Dim thebodies As New List(Of Body)
Try
Dim BodyTag As Tag = Tag.Null
Do
ufs.Obj.CycleObjsInPart(thePart.Tag, UFConstants.UF_solid_type, BodyTag)
If BodyTag = Tag.Null Then
Exit Do
End If
Dim theType As Integer, theSubtype As Integer
ufs.Obj.AskTypeAndSubtype(BodyTag, theType, theSubtype)
If theSubtype = UFConstants.UF_solid_body_subtype Then
thebodies.Add(Utilities.NXObjectManager.Get(BodyTag))
End If
Loop While True
Catch ex As NXException
lw.WriteLine(ex.ErrorCode & ex.Message)
End Try
Return thebodies
End Function
I did something similar with
I did something similar with this code
Dim J As integer
For Each myFeature As Features.Feature In theSession.Parts.Work.Features.GetFeatures()
If myFeature.FeatureType= "FSET" Then
theUfSession.Modl.AskAllMembersOfSet(myFeature.tag, List_groups, i)
for J = 0 to i - 1
'...
Next
End If
Next
re: component group bodies
I've not dealt with the "wrap" functions as yet, I assume that you will need the occurrence bodies for this to work correctly. To get the occurrence bodies of a specific component group, 2 different strategies come to mind:
I tend to favor the first option, a couple of easy checks will tell you if the body belongs to a component in the group. The second option would require more code and would probably require the components to be fully loaded.
In either case, be careful will deformed or promoted components (perhaps also wave-linked bodies) as these may need some special handling.