Hello
I am attempting to use the API to copy a part in the active station.
The following code works well, except when the part has many entities, it takes some time to complete.
Private Sub CopyPart()
Dim p As Part
Dim e As Entity
Dim cbpCommandBarPopup As RSEXT.CommandBarPopup
ActiveStation.UCS = ActiveStation
Set p = ActiveStation.Parts.Add
'catches the edit menu for the copy paste commands
Set cbpCommandBarPopup = RSE.CommandBars(“Menu Bar”).Controls(“Edit”)
'Copies the parts
ActiveStation.Selections.RemoveAll
For Each e In ActiveStation.Parts(“part_to_copy”).Entities()
ActiveStation.Selections.Add e
Next e
cbpCommandBarPopup.Controls(“Copy”).Execute
ActiveStation.Selections.RemoveAll
ActiveStation.Selections.Add p
cbpCommandBarPopup.Controls(“Paste”).Execute
End Sub
How does one just copy a part, without haveing to traverse through all of the entities?
I tried the following without success:
Private Sub CopyPart()
Dim p As Part
Dim cbpCommandBarPopup As RSEXT.CommandBarPopup
'catches the edit menu for the copy paste commands
Set cbpCommandBarPopup = RSE.CommandBars(“Menu Bar”).Controls(“Edit”)
'Copy the part
ActiveStation.Selections.RemoveAll
ActiveStation.Selections.Add ActiveStation.Parts(“part_to_copy”)
cbpCommandBarPopup.Controls(“Copy”).Execute
ActiveStation.Selections.RemoveAll
ActiveStation.Selections.Add ActiveStation
cbpCommandBarPopup.Controls(“Paste”).Execute
End Sub
The key must be the line :ActiveStation.Selections.Add ActiveStation
But I have tried many different things without success.
I was successful in copying into an assembly by just the part reference, but how do you paste into the components part of the station? :question:
Looking forward to your reply.
Tom