Inserting the same part multiple times with the same constraints

Inserting the same part multiple times with the same constraints

Odalv
Contributor Contributor
713 Views
3 Replies
Message 1 of 4

Inserting the same part multiple times with the same constraints

Odalv
Contributor
Contributor

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?

0 Likes
Accepted solutions (1)
714 Views
3 Replies
Replies (3)
Message 2 of 4

Cadkunde.nl
Collaborator
Collaborator
Accepted solution

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
0 Likes
Message 3 of 4

Odalv
Contributor
Contributor

Brilliant! That was exactly what I need! 

Many thanks!

0 Likes
Message 4 of 4

P_Korgaonkar
Advocate
Advocate

How is this code used? 

Is the Ilogic code saved in an assembly or in the part file?

 

I want to achieve the same; every time I place a part in my assembly, I want its base to be constrained to the xy plane.

 

Thanks in Advance

 

0 Likes