Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Macro to position CATPart and its instances at specific coordinates

Status
Not open for further replies.

pravs

Mechanical
Apr 12, 2018
34
Hello,
I am trying to create a macro to automate the positioning of desired Catpart in a product onto a desired coordinates . I know the coordinates . I tried to record a macro by using 'snap' command but the code generated was not suitable. Please help me out.

Thanks in advance
 
Replies continue below

Recommended for you

Do you insert a new file or is already existing in the product? Are you working in a database (for example VPM)? Are you working with files on a network?
These are just some questions which you need to clarify if you want to point a developer in the right way...or your searches...
If you will search the forum with keyword insert you will find also some relevant posts.

Regards
Fernando

 
How i see this , the catpart should have related his driving geometry to a point inside with coordinates acording to absolute axis . When inserting the part, macro should read this point and change coordinates to new imput values .Is this what you want ?

Regards,
Tudor
 
Hi,
The part is already inserted and is at some random position . The part and its corresponding instances have to get positioned automatically to a specific set of points( I have a macro to get coordinates of these points).
 
Hi.

Use this snippet:
Code:
Dim pos(11)
partInstance.Position.GetComponents pos

pos(9) = newX
pos(10) = newY
pos(11) = newZ
partInstance.Position.SetComponents pos
 
Hi Little Cthulhu,
The code is working, thank you so much . I am facing a minor error, I am trying to get coordinates of points where the part instances have to be positioned so I used the below lines of code. But the part instances are being placed at different x,y,z . I don't understand where I am going wrong.
pos(0) = coords(0)
pos(1) = coords(1)
pos(2) = coords(2)
 
Why on earth would you change my working code and then ask "why it doesn't work"?

Don't you think I used 9,10,11 for a reason?
 
Hi,
Sorry That was a typo. I used 9,10,11 only . The minor error I mentioned still remains the same.
 
Are you moving parts inside a multi-level assembly with different coordinate systems at each level?
 
Are you moving parts inside a multi-level assembly with different coordinate systems at each level?

And [tt]SetComponents[/tt] sets position in local coordinate system. You have to do some math to calculate coordinates in global axis system.

See this thread at COE.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor