Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Odalv
315 Views, 2 Replies

Inserting the same part multiple times with the same constraints

Hello!
I have a part that I need to insert into the assembly multiple times. Every time I insert this part, I need to make two constraints: the Z axis (Mate) and the XY plane (Flush).

Basically, I need to insert multiple occurrences of the same part, but with the same two constraints. The other constraints are different and I cannot use pattern.

I have found relatively simple code for constraining one instance of this part. But it will not work if I insert the same part multiple times because of the "occurence" number (marked with red) beside the part name.


Constraints.AddMate("Mate:1", "PartA:1", "Z Axis", "", "Z Axis",)
Constraints.AddFlush("Flush:1", "PartA:1", "XY Plane", "", "XY Plane")


I have tried to use only "" instead of part name, but that didn't work.

Would it be possible to use iLogic to automate this process?

Cadkunde.nl
in reply to: Odalv

Try using for/next statement

 

For i = 1 To 10
	Constraints.AddMate("Mate:" & i, "PartA:" & i, "Z Axis", "", "Z Axis",)
	Constraints.AddFlush("Flush:" & i, "PartA:" & i, "XY Plane", "", "XY Plane")
Next
Odalv
in reply to: Cadkunde.nl

Brilliant! That was exactly what I need! 

Many thanks!