Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Axis system full path

TiagoFigueiredo

Industrial
May 22, 2013
503
I everyone.

I'm trying to create a macro to constrain components to axis system. And for create constraints I need the full path of axis system location. Ex:
1737546094433.png

To start thinking the structure of macro, I've made a small piece of code. where I select the axis system and returns it's name. Until here really straight foward. But to achive the full path of axis system location, I've no idea of how to do it.
For this selected one, it should return : "COMPONENTS/BUSH 1/LOWER/ Axis System.4"

Any idea of how to do it?

Just recorded a macro of constraint creation:

1737546519694.png
 
Replies continue below

Recommended for you

Hi Tiago, select the Axis System, and set
part1.InWorkObject=sel.item(1).value
Set CurrentHBody = part1.InWorkObject

that will set the parent geo-set as "Define in Work Object" -- and from here you can navigate your way up to the top, right?...
 
Hello Tiago

I'm a die designer so I need axis like yours. Every standard part needs the axis.

I created a macro for this I record my informations to textbox and ArrayList after in cycle I get my axises for constrain in Product.

I manage like this :) for every gas springs, steels, plates in lowerupper grup cam unit etc etc...

Code:
For Each item In AxesList
    Dim oRef
    strRef = rootProductName & "/" & AxesMainSketchProductName & "/!" & item
    oRef = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & AxesMainSketchProductName & "/!" & item)
    refOfMainSketchAxisList.Add(oRef)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of AxesList in Main Sketch: " & strRef)
Next

For Each item In STDProductNameList
    Dim oRef1
    strRef = rootProductName & "/" & item & "/!" & STDAxisName
    oRef1 = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & item & "/!" & STDAxisName)
    refOfSTDPartAxisList.Add(oRef1)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of STDProductNameList of copied STD: " & strRef)
Next
Dim oConstraints As Constraints = oDoc.Product.Connections("CATIAConstraints")

For i As Int16 = 0 To refOfSTDPartAxisList.Count - 1
    Dim iConstraint As Constraint
    iConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, refOfMainSketchAxisList(i), refOfSTDPartAxisList(i))
Next

oDoc.Product.Update()
 
Last edited:
Can
Hello Tiago

I'm a die designer so I need axis like yours. Every standard part needs the axis.

I created a macro for this I record my informations to textbox and ArrayList after in cycle I get my axises for constrain in Product.

I manage like this :) for every gas springs, steels, plates in lowerupper grup cam unit etc etc...

Code:
For Each item In AxesList
    Dim oRef
    strRef = rootProductName & "/" & AxesMainSketchProductName & "/!" & item
    oRef = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & AxesMainSketchProductName & "/!" & item)
    refOfMainSketchAxisList.Add(oRef)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of AxesList in Main Sketch: " & strRef)
Next

For Each item In STDProductNameList
    Dim oRef1
    strRef = rootProductName & "/" & item & "/!" & STDAxisName
    oRef1 = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & item & "/!" & STDAxisName)
    refOfSTDPartAxisList.Add(oRef1)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of STDProductNameList of copied STD: " & strRef)
Next
Dim oConstraints As Constraints = oDoc.Product.Connections("CATIAConstraints")

For i As Int16 = 0 To refOfSTDPartAxisList.Count - 1
    Dim iConstraint As Constraint
    iConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, refOfMainSketchAxisList(i), refOfSTDPartAxisList(i))
Next

oDoc.Product.Update()
Can you please provide the full script
 
Hello Tiago

I'm a die designer so I need axis like yours. Every standard part needs the axis.

I created a macro for this I record my informations to textbox and ArrayList after in cycle I get my axises for constrain in Product.

I manage like this :) for every gas springs, steels, plates in lowerupper grup cam unit etc etc...

Code:
For Each item In AxesList
    Dim oRef
    strRef = rootProductName & "/" & AxesMainSketchProductName & "/!" & item
    oRef = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & AxesMainSketchProductName & "/!" & item)
    refOfMainSketchAxisList.Add(oRef)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of AxesList in Main Sketch: " & strRef)
Next

For Each item In STDProductNameList
    Dim oRef1
    strRef = rootProductName & "/" & item & "/!" & STDAxisName
    oRef1 = oDoc.Product.CreateReferenceFromName(rootProductName & "/" & item & "/!" & STDAxisName)
    refOfSTDPartAxisList.Add(oRef1)
    txtStatus.AppendText(vbNewLine & DateTime.Now & " strRef of STDProductNameList of copied STD: " & strRef)
Next
Dim oConstraints As Constraints = oDoc.Product.Connections("CATIAConstraints")

For i As Int16 = 0 To refOfSTDPartAxisList.Count - 1
    Dim iConstraint As Constraint
    iConstraint = oConstraints.AddBiEltCst(CatConstraintType.catCstTypeOn, refOfMainSketchAxisList(i), refOfSTDPartAxisList(i))
Next

oDoc.Product.Update()
Hello, Many thanks by your share. It will be really usefull. By the Way, I was die designer for about 15 years. I know your pain!
 
Hello, Many thanks by your share. It will be really usefull. By the Way, I was die designer for about 15 years. I know your pain!
Tiago, how can I manage same part to copying bodies of add removes in product? I can manage different parts with macro but in same parts it is not working. Could you give me an information? Here is example file.
 

Attachments

  • forEngTip.zip
    69.5 KB · Views: 4

Part and Inventory Search

Sponsor