Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying multiple axis to a part file

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274
GB
Hi Gents,
I'm trying to find a way to copy the axis systems from each of the parts in a product and put them in a single part file and rename each with the instance name.
I haven't had a go at any batch macro's yet so any pointer would be a big help.
I'm not even sure this can be done so don't laugh :)

regards
Alan
 
Replies continue below

Recommended for you

IMHO it is possible-you should probably deal with the parts recursively (Generally speaking you don't know the depth of your product structure).
Even your Axis systems do not necessarily exist in the AxisSystems node, but I guess a search within a part will do. Appending an instance name after copy-paste shouldn't be a problem.

regards,
LWolf
 
instead of the axis you might want to consider the position of the instance... depends what you need. Absolute Axis in V5 or V6/3DX is not like V4 absolute axis (which was at (0,0,0) and could not be moved).

Eric N.
indocti discant et ament meminisse periti
 
I have to take the axis from each part (and instance) and copy them to a 'Skeleton' part in the product. Each axis has to be named as the instance.
Products inside that product would be positioned on the Absolute axis so don't need to be added.
It's just a pain when you have a load of parts & fasteners that need to be added.
I'll start with creating a new part and then look at what I can find in the portable script center or the net.

cheers guys
 
This is so far beyond my abilities lol
If any of you guys have something along those lines that I could try and modify I would be grateful.
I'm trying to mod the instance rename code from PS Center but getting nowhere
 
I've spent a while on this and realise I don't understand enough to do it.
In other words I have gotten nowhere.
Does anyone have something that explains how the code would work through the part files.
I'm not asking for anyone to write the code for me, just to give me a nudge in the right direction.

regards
Alan
 
I'd start by managing to copy ALL axis systems (if they only reside in the Axis Systems node, then you can access them directly (Part.AxisSystems), but if some of them are in GeoSets, then you need to "selection.search" for those--just as you would do with Ctrl+F functionality in CATIA ('Generative Shape Design'.'Axis System';all)) from one part to a new one (Paste Special as Result).
Once you have this working, I'd try to understand how to retrieve a part's instance name.
And then how to loop through all parts of the assembly--independent on how many nested sub assys there are, i.e recursively.


regards,
LWolf
 
Thanks LWolf,
All the Axis systems are in the Axis system nodes.
I was hoping to use a loop to run through each part in the product.
on each loop it would copy the axis system to "File-1", rename the axis system with the part instance name then got to the next part and loop the code again.
I'm probably being naïve thinking it could be that simple.
 
yupp, that's what I've outlined in my previous post, albeit a little bit closer to the actual script :)

regards,
LWolf
 
Hi,

I have found this code that selects all the axis systems. I have also used the same code to count the selected parts so I can check there is only one axis in each part.
After that I'm stuck lol
I'm assuming that this code would allow me to copy the axis systems one at a time into another part but how? I've been searching the net all day and got nowhere.
Probably because I don't know what i'm actually looking for.
Could someone please give me a pointer.

regards
Alan

Dim objSel 'As Selection
Set objSel =CATIA.ActiveDocument.Selection
objSel.Search ("CATGmoSearch.AxisSystem,sel")
objcount = objSel.count

Dim i 'As Integer

For i = 1 to objSel.Count
objSel.Item(i).Value.Name = objSel.Item(i).Value.Name&i

Next i
 
Gents,
I've been playing around with the code below and actually got the axis systems to be deleted.
I couldn't figure out how the selection worked but this seems too.
What I can't figure is how to point the paste option to a target file?
I have tried recording it but the resulting code dosen't seem to work.
I have also just got the course from Emmet Ross but need the time to do it properly.
So if someone could help it would be appreciated.

Sub CATMain()

Dim sSel 'As Selection
Set sSel = CATIA.ActiveDocument.Selection
sSel.Search "CATGmoSearch.AxisSystem,sel"
icount = sSel.Count
'MsgBox icount

Dim i 'As Integer
For i = 1 To sSel.Count
sSel.Item(i).Value.Name = sSel.Item(i).Value.Name&i
'sSel.Delete

'---set/get target for paste----

?

'----------------------
 
They are all in named parts but are all called absolute axis system.
When copied to the collector part they will be renamed with the part name. (or part of the part name).
The collector will be called Skel.1 and I will be creating that manually. The code above seems to work ok deleting the files so I was hoping it would do the same copying. I just cant sus out how to point the copy to the Skel file.
There doesn't seem much info on how you point to files or directories when doing macros.
That's probably because its basic and second nature to you guys.

cheers
Alan
 
I m not sure only if u copy those Axis are they gonna be in the absolute axis system
or in the place where part is, because you constraint it, i must check it.

What you want to do is to select first this skeleton part, then lets say you choose one
assemble and select all part from that assembly, you mast Use array to store this parts
and you must use For loop, and this Array will control the loop. In the array you have
all information which u need for rename those Axis.

For the beginning try to make macro which will copy Axis system from one part to another, if
you do it right just array now and for loop and u solve it.

Here is video about single selection:

And about multiple selection:

I can also make vide how to copy with link from one part to another
 
Hello Alan,

Did you ever figure it out? I'm trying to do the same thing. I did click on the youtube links but nothing pops up.

Thanks,

Aaron
 
Hi Aaron,
I did manage to get something to work although it's not exactly what I wanted.
The collector needs to be added before you start and named 'TempAxisCollector.CATPart'. You can rename it later if you wish.
If you select the part containing the axis system and run it will copy it into the collector and rename it.
The parts I have use a 32 character name but I only wanted to use 6 of them. the code extracts the ones I want.
unfortuanetly I couldn't get it to do a multiple selection so I have to do one part at a time.
It has saved me a lot of hours though.
I'm sure some of the guys on here could make it work.
excuse the code, I'm just learning :)
alan


Sub CATMain()
Dim uSel 'As User Selection
Set uSel = CATIA.ActiveDocument.selection
Dim nSel 'As Name
nSel = uSel.item(1).value.name
Dim nSel2
nSel2 = nSel
CStr(nSel2)
Dim nSel3 'gets Part number
nSel3 = Mid(nSel2 , 19, InStr(nSel2 , ".") -25)
Dim nSel4 'gets instance number
nSel4 = Mid(nSel2 , 33, InStr(nSel2 , ".") -1)
Dim sSel
Set sSel = uSel
Set visProperties1 = uSel.VisProperties 'Hide Part
visProperties1.SetShow catVisPropertyNoShowAttr
sSel.Search "CATGmoSearch.AxisSystem,sel"
sSel.Copy()
' MAKE COLLECTOR ACTIVE FOR PASTE
Dim documents1 'As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 'As Document
Set partDocument1 = documents1.Item("TempAxisCollector.CATPart")
Dim part1 'As Part
Set part1 = partDocument1.Part
Dim selectPart
Set selectPart = CATIA.ActiveDocument.Selection
sSel.Add(partDocument1.Part)
sSel.PasteSpecial("CATPrtResult")
Dim pSel
Set pSel = CATIA.ActiveDocument.selection
pSel.item(1).value.name = nSel3 & nSel4
uSel.Clear()
pSel.Clear()
End sub
 
Calin,
If there is a way of selecting the collector and then multiple parts that would really help speed this up.
When I tried a multi-selection it only ever copied the last instance of each part.
ie, if there were 30 parts named "Nut" it would only copy "Nut.30"

regards
Alan
 
Hello Alan,

Thanks for you response! I will see if I can get this to work for me! The way I've been doing it is turning the whole product into a catPart and then renaming all of the axis systems that come into the part manually. IE: if the part in the product tree is 8350-0058 and I had 10 on them in the tree I'd manually add 1 thru 10 at the end of each name so that I can export the design table so I can use the data in the X,Y,Z and all the vectors of each.

Thanks,

Aaron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top