Telcontar
Automotive
- Jul 10, 2014
- 22
I've got a Product Structure with under-products and parts within. Each part, among others, has got two GeoSets named: "Part_Geometry" and "RPS_Elements". My goal is to:
- copy "Part_Geometry" from every part
- paste special without link into the newly created part called MAIN.CATPart;
- rename "Part_Geometry" with name as PartName which it came from (Parent.name maybe?)
- copy "RPS_Elements" from every part and paste it without link into the MAIN.CATPart.
Now I'm stuck on getting all Parts into selection (PartSet) and can't go further. Could someone please review and correct me?
Any comment would be appreciated
Best regard
Lucas
- copy "Part_Geometry" from every part
- paste special without link into the newly created part called MAIN.CATPart;
- rename "Part_Geometry" with name as PartName which it came from (Parent.name maybe?)
- copy "RPS_Elements" from every part and paste it without link into the MAIN.CATPart.
Code:
Sub CATMain()
Set documents1 = CATIA.Documents
' Part erstellung und umbennenung / part creation and naming
Set partDocument1 = documents1.Add("Part")
Set product1 = partDocument1.GetItem("Part5")
product1.PartNumber = "MAIN"
' Fensterbehandlung / window tilling
Set windows1 = CATIA.Windows
windows1.Arrange catArrangeTiledVertical
Set specsAndGeomWindow1 = windows1.item(1)
specsAndGeomWindow1.Activate
dim Partset
dim Copyset
dim Hybridbody1
dim PasteSet
' Parts Collection
Set PartSet = CATIA.ActiveDocument.Selection
PartSet.clear
PartSet.search "(CATAsmSearch.Part),all"
'Loop fuer Geosets copy und paste / Loop for copy/paste
For i=1 to PartSet.Count
Set ActiveDocu = PartSet.Item(i)
Set ActivePart = ActiveDocu.Part
Set Hybridbodies = PartSet.Item(i).HybridBodies
Set Hybridbody1 = Hybridbodies.Item("RPS_Elements")
Set Hybridbody2 = Hybridbodies.Item("Part_Geometry")
Copyset.Add Hybridbody1
Copyset.Add Hybridbody2
Copyset.copy
Set specsAndGeomWindow2 = windows1.item(product1)
specsAndGeomWindow2.Activate
Set PasteSet = product1.selection
PasteSet.Add product1
PasteSet.PasteSpecial "CATPrtAsResult"
product1.Update
specsAndGeomWindow1.Activate
next
product1.update
End Sub
Now I'm stuck on getting all Parts into selection (PartSet) and can't go further. Could someone please review and correct me?
Any comment would be appreciated
Best regard
Lucas