×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Copying multiple axis to a part file

Copying multiple axis to a part file

Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

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

RE: Copying multiple axis to a part file

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

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

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

RE: Copying multiple axis to a part file

(OP)
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.

RE: Copying multiple axis to a part file

yupp, that's what I've outlined in my previous post, albeit a little bit closer to the actual script :)

regards,
LWolf

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

(OP)
I give up lol

RE: Copying multiple axis to a part file

(OP)
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----

?

'----------------------

RE: Copying multiple axis to a part file

Those Axis in parts does they have same name or different?

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

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:
https://www.youtube.com/watch?v=BKMIsmYl598

And about multiple selection:
https://www.youtube.com/watch?v=LJ6ueJ1FLFQ

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

RE: Copying multiple axis to a part file

(OP)
thanks for the reply.
I'll take a look :)

regards
Alan

RE: Copying multiple axis to a part file

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

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

(OP)
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

RE: Copying multiple axis to a part file

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

RE: Copying multiple axis to a part file

Also, is this in VBA or CATScript? I'm getting some red word's and wondering if it's because I'm using VBA. Thanks!

RE: Copying multiple axis to a part file

There are no error trappers, loose checks but it can be easily adjusted.
- It works in my setup (CATVBA, V5R21, Win7 64bits).
- It copies from multiple instances of the same part with respect to relative position within the assembly.
- It goes recursively to all levels of the active Product.

CODE -->

Dim oProdSelection As Selection
Dim oSkelDoc As PartDocument

Sub CATMain()
    
    Dim oProdDoc As ProductDocument
    Dim oProd As Product

    Set oProdDoc = CATIA.ActiveDocument
    Set oProd = oProdDoc.Product
    Set oProdSelection = oProdDoc.Selection
    oProdSelection.Clear
    
    'modify next line to make sure that this is the Axis Systems skeleton repository
    Set oSkelDoc = oProd.Products.Item("Skel.1").ReferenceProduct.Parent
    
    CATIA.HSOSynchronized = False
    Call ProcessAxisSystems(oProd)
    CATIA.HSOSynchronized = True
End Sub
Sub ProcessAxisSystems(oProd As Product)
    Dim oChildProd As Product
    For Each oChildProd In oProd.Products
        If oChildProd.HasAMasterShapeRepresentation Then
            'it is a part. you can do whatever checks you'd like to make sure that this is a Part indeed.
            'for the next line adjust the condition in order to identify the skeleton itself and
            'to avoid copying-pasting from the same part.
            If oChildProd.ReferenceProduct.PartNumber <> "Skel" Then
                oProdSelection.Clear
                oProdSelection.Add oChildProd
                oProdSelection.Search "(((FreeStyle.'Axis System' + 'Part Design'.'Axis System') + 'Generative Shape Design'.'Axis System') + 'Functional Molded Part'.'Axis System'),sel"
                oProdSelection.Copy
                oProdSelection.Clear
                oProdSelection.Add oSkelDoc.Part
                oProdSelection.PasteSpecial ("CATPrtResult")
                oProdSelection.Clear
                oSkelDoc.Part.Update
                oSkelDoc.Part.AxisSystems.Item(oSkelDoc.Part.AxisSystems.Count).Name = oChildProd.Name
            'Else
                'this is the Skel part
            End If
        Else
            Call ProcessAxisSystems(oChildProd)
        End If
    Next
End Sub 

RE: Copying multiple axis to a part file

(OP)
Hi Aaron,
It's catscript.
I cant run macros on customer sites so I have to use scripts from a usb :(

RE: Copying multiple axis to a part file

Well, I just put that code in a CATScript and it ran flawlessly.

Did you try it?

Calin


Oh, sorry, you were talking with Aaron. My bad bigglasses

RE: Copying multiple axis to a part file

(OP)
cilici,
Don't think you could do bad even if you tried :)
going to have a play with the code you posted. thanks for sharing

alan

RE: Copying multiple axis to a part file

Hello all,


Thank you all for your help, I'm going to try this out :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close