thread560-367939
hello; I am trying to copy contents of selected GeoSets and paste it to separate Parts, one part for each selected Set. if my Selection consists of Main Set, and SubSet1 and SubSet2, I'd like to get three files, one containing the Main Set (and both SubSets), one with SubSet1 and one with SubSet2. so far I have something that I have copy-pasted from several threads, but I get three replicas of ALL the sets...
Sub CATMain()
Dim USel As Selection
Dim USelLB
Dim InputObject(0)
Dim oStatus
Dim oListBox
InputObject(0) = "HybridBody"
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel
USel.Clear
oStatus = USelLB.SelectElement3(InputObject, "Select objects to list names", True,CATMultiSelTriggWhenUserValidatesSelection, False)
If (oStatus = "Cancel") Then 'User hit esc on keyboard
MsgBox "Macro canceled by user"
Exit Sub
Else 'Loop through selected objects and copy contents
For i = 1 to USel.Count
Set oSet = USel.Item(i).Value
For Each s In oSet.HybridShapes
USel.Add s
USel.Copy ' Copy the Geometry
USel.Clear ' Clear the selection
' create second part
Dim part2
Set part2 = CATIA.Documents.Add("CATPart") ' Makes a new CATPart and thusly, new actdoc
Set ActDoc = CATIA.ActiveDocument ' New ActDoc
' Retrieving HybridBodies collection in Part Document
Dim hybridBodies2 As HybridBodies
Set hybridBodies2 = part2.Part.HybridBodies
Dim GSet1 As HybridBody
Set GSet1 = part2.Part.HybridBodies.Item(1)
Set USel = ActDoc.Selection ' Create an object of selection for the Target document
USel.Add GSet1 ' Add the Set where the copied data will be pasted in the selection
USel.PasteSpecial("CATPrtResultWithOutLink")
Next
Next
End If
USel.Clear
End Sub
regards,
LWolf
hello; I am trying to copy contents of selected GeoSets and paste it to separate Parts, one part for each selected Set. if my Selection consists of Main Set, and SubSet1 and SubSet2, I'd like to get three files, one containing the Main Set (and both SubSets), one with SubSet1 and one with SubSet2. so far I have something that I have copy-pasted from several threads, but I get three replicas of ALL the sets...
Sub CATMain()
Dim USel As Selection
Dim USelLB
Dim InputObject(0)
Dim oStatus
Dim oListBox
InputObject(0) = "HybridBody"
Set USel = CATIA.ActiveDocument.Selection
Set USelLB = USel
USel.Clear
oStatus = USelLB.SelectElement3(InputObject, "Select objects to list names", True,CATMultiSelTriggWhenUserValidatesSelection, False)
If (oStatus = "Cancel") Then 'User hit esc on keyboard
MsgBox "Macro canceled by user"
Exit Sub
Else 'Loop through selected objects and copy contents
For i = 1 to USel.Count
Set oSet = USel.Item(i).Value
For Each s In oSet.HybridShapes
USel.Add s
USel.Copy ' Copy the Geometry
USel.Clear ' Clear the selection
' create second part
Dim part2
Set part2 = CATIA.Documents.Add("CATPart") ' Makes a new CATPart and thusly, new actdoc
Set ActDoc = CATIA.ActiveDocument ' New ActDoc
' Retrieving HybridBodies collection in Part Document
Dim hybridBodies2 As HybridBodies
Set hybridBodies2 = part2.Part.HybridBodies
Dim GSet1 As HybridBody
Set GSet1 = part2.Part.HybridBodies.Item(1)
Set USel = ActDoc.Selection ' Create an object of selection for the Target document
USel.Add GSet1 ' Add the Set where the copied data will be pasted in the selection
USel.PasteSpecial("CATPrtResultWithOutLink")
Next
Next
End If
USel.Clear
End Sub
regards,
LWolf