Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Flexible/Rigid Sub-Assembly - CATIA VBA

Status
Not open for further replies.

Jegsaran

Automotive
Dec 16, 2020
41
0
0
IN
I'm working on a macro which copy/paste a product into a new product document and constrain it.
Whenever I paste the product in an assembly in new product document it changes the sub-assy into flexible sub-assembly.

I tried Catia.StartCommand("Flexible/Rigid Sub-Assembly"). But if the sub-assy is rigid, it changes to flexible.
All I want is to check whether the sub-assy flexibe/rigid. If flexible want to change as rigid.
 
 https://files.engineering.com/getfile.aspx?folder=be866ed1-1ab9-49a2-9190-dbcb6faca834&file=Rigid_Flexible_sub_assy.PNG
Replies continue below

Recommended for you

You could check it with something like this::

Code:
Dim constraints1 As Constraints
Set constraints1 = oProd.ReferenceProduct.Connections("CATIAConstraints")
Dim constraints2 As Constraints
Set constraints2 = oProd.Connections("CATIAConstraints")
Dim constraint1 As Constraint
Dim constraint2 As Constraint
Set constraint1 = constraints1.Item(1)
Set constraint2 = constraints2.Item(1)
If constraint1.Name = constraint2.Name Then
    'rigid
Else
    'flexible
End If

It's true that all your Assemblies need constraints for upper code to work, but I belive that they do have them.
 
The idea is to check the name of first constraint inside newly inserted subassembly. If the product is flexible, all the constraint names inside it get index ".1". Ergo if a constraint name inside certain product instance is different from the name of the same constraint inside given referenceproduct, then the product instance is flexible.

edit:

If you don't have any constraints inside inserted subassembly, you can always create one (fix first part inside subassembly) and delete it after "check".
 
Status
Not open for further replies.
Back
Top