Code:
Dim visibleObjects() As DisplayableObject = workPart.Views.WorkView.AskVisibleObjects()
Dim theBodyList As New List(Of Body) For Each theVisObj As DisplayableObject In visibleObjects
If TypeOf theVisObj Is Body Then
theBodyList.Add(theVisObj)
End If
Next
Dim theComponent As Part = workPart
Dim loadStatus As PartLoadStatus = Nothing
Dim fn = Environment.GetEnvironmentVariable("UGII_USER_DIR") & "\application\CreatePictureV2\LogoParts\temp_part.prt"
Dim theTempPart As Part = theSession.Parts.OpenActiveDisplay(fn, DisplayPartOption.ReplaceExisting, loadStatus)
theSession.Parts.SetWork(theTempPart)
workPart = theSession.Parts.Work
Dim thePoint As New Point3d(0, 0, 0)
Dim theOrientation As New Matrix3x3()
With theOrientation
.Xx = 1
.Xy = 0
.Xz = 0
.Yx = 0
.Yy = 1
.Yz = 0
.Zx = 0
.Zy = 0
.Zz = 1
End With
theSession.Parts.Work.ComponentAssembly.AddComponent(theComponent, "Entire Part", theComponent.Name, thePoint, theOrientation, -1, loadStatus)
'Körper linken, nicht assoziativ
For Each theBody As Body In theBodyList
Dim theBodyArr2(0) As Body
If theBody.Prototype Is Nothing Then
theBodyArr2(0) = theBody
Else
theBodyArr2(0) = theBody.Prototype
End If
Dim waveLinkBuilder1 As WaveLinkBuilder = workPart.BaseFeatures.CreateWaveLinkBuilder(Nothing)
Dim extractFaceBuilder1 As ExtractFaceBuilder = waveLinkBuilder1.ExtractFaceBuilder
With waveLinkBuilder1
.Type = WaveLinkBuilder.Types.BodyLink
.Associative = False
.MakePositionIndependent = False
.FixAtCurrentTimestamp = False
.BlankOriginal = False
.CopyThreads = True
End With
Dim scCollector1 As ScCollector = extractFaceBuilder1.ExtractBodyCollector
With extractFaceBuilder1
.FaceOption = ExtractFaceBuilder.FaceOptionType.FaceChain
.ParentPart = ExtractFaceBuilder.ParentPartType.OtherPart
.Associative = False
.MakePositionIndependent = False
.FixAtCurrentTimestamp = False
.HideOriginal = False
.InheritDisplayProperties = True
.FeatureOption = ExtractFaceBuilder.FeatureOptionType.SeparateFeatureForEachBody
.CopyThreads = True
End With
Dim rules1(0) As SelectionIntentRule
Dim bodyDumbRule1 As BodyDumbRule = workPart.ScRuleFactory.CreateRuleBodyDumb(theBodyArr2, True)
rules1(0) = bodyDumbRule1
scCollector1.ReplaceRules(rules1, False)
waveLinkBuilder1.CommitFeature()
waveLinkBuilder1.Destroy()
Next