copy from one Geometrical set to another
copy from one Geometrical set to another
(OP)
I want to copy from one geometrical set to others based on the layer assignment in the original. i can determine the layer and create all of the other sets i need. I thought that a copy and pastespecial would work but it just pastes it under the first one in the original set. So how do you set where the paste is going to be applied? i have a this as part of the code
part1.InWorkObject = part1.HybridBodies.Item("Where I want it")
CATIA.ActiveDocument.Selection.Copy
part1.InWorkObject = part1.HybridBodies.Item("Where I want it")
CATIA.ActiveDocument.Selection.Add(part1.HybridBodies.Item("Where I want it"))
CATIA.ActiveDocument.Selection.PasteSpecial "CATPrtResultWithOutLink"
Or if there is a better way to do it let me know.
part1.InWorkObject = part1.HybridBodies.Item("Where I want it")
CATIA.ActiveDocument.Selection.Copy
part1.InWorkObject = part1.HybridBodies.Item("Where I want it")
CATIA.ActiveDocument.Selection.Add(part1.HybridBodies.Item("Where I want it"))
CATIA.ActiveDocument.Selection.PasteSpecial "CATPrtResultWithOutLink"
Or if there is a better way to do it let me know.





RE: copy from one Geometrical set to another
Its not my code, unfortunately I didn't notice where I found it...
Sub CATMain()
Dim part1 As PartDocument
Set part1 = CATIA.Documents.Add("CATPart") ' create new part (use this code on an empty session of CATIA)
Dim ActDoc As Document
Set ActDoc = CATIA.ActiveDocument ' Makes the Current Document the Active one
Dim HSF As HybridShapeFactory
Set HSF = part1.Part.HybridShapeFactory ' Provides the Shape Factory
' Retrieving HybridBodies collection in Part Document
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.Part.HybridBodies
Dim GSet As HybridBody
Set GSet = hybridBodies1.Add()
Set GSet = part1.Part.HybridBodies.Item(1) ' Makes an abitrary Geometrical Set
' make some geometry
Dim Pt1, Pt2, Pt3 As HybridShapePointCoord ' Makes abitrary geometry to do the copy/paste
Set Pt1 = HSF.AddNewPointCoord(10, 20, 30)
Set Pt2 = HSF.AddNewPointCoord(10, -20, -30)
Set Pt3 = HSF.AddNewPointCoord(-10, 20, 30)
GSet.AppendHybridShape Pt1
GSet.AppendHybridShape Pt2
GSet.AppendHybridShape Pt3
part1.Part.Update
Set ActSel = ActDoc.Selection ' This is the Selection Object
ActSel.Add Pt1 ' Add the Geometry to the Object
ActSel.Add Pt2
ActSel.Add Pt3
ActSel.Copy ' Copy the Geometry
ActSel.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 = hybridBodies2.Add()
Set GSet1 = part2.Part.HybridBodies.Item(1)
Set ActSel = ActDoc.Selection ' Create an object of selection for the Target document
ActSel.Add GSet1 ' Add the Set where the copied data will be pasted in the selection
ActSel.Paste ' Pastes in the new Window
End Sub
Regards
Fernando
RE: copy from one Geometrical set to another
This example gave me what i needed.
As it turns out adding a selection.clear right after the selection.copy was the answer.
ActSel.Copy
ActSel.Clear
ActSel.Add(part1.HybridBodies.Item("Where I want it"))
ActSel.PasteSpecial "CATPrtResultWithOutLink"