Occurrence Position

Phenom
Phenom

Could anyone tell me how I get the position of a selected part (or assembly) in an assembly.

I'm trying to create a macro to copy selected items from one assembly into a new assembly and maintain their positions relative to the base co-ordinate system.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.
6 REPLIES

Re: Occurrence Position

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

These come to mind:

 

void GetOrigin(out Double OriginX, out Double OriginY, out Double OriginZ)
Member of SolidEdgeAssembly.Occurrence

Summary:

Returns the origin for the referenced object.

 

void GetMatrix(ref Double[] Matrix)
Member of SolidEdgeAssembly.Occurrence

Summary:

Returns the transformation matrix for the referenced occurrence.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Occurrence Position

Phenom
Phenom

Thanks Jason.

I will have a look at those - could be a while before I get round to it though.

I had a look with Spy but couldn't see anything that looked like an origin when I selected something.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Occurrence Position

Siemens Phenom Siemens Phenom
Siemens Phenom

If you are wanting them to be in the same relative position, you will probably want to use the matrix instead of the origin so that any rotation is taken into account.

 

Greg

Re: Occurrence Position

Phenom
Phenom

Thanks Greg,

I guessed that would be the case, although how I do it I haven't a clue.

I'm a bit too busy with my proper work to do it at the moment.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Occurrence Position

Phenom
Phenom

Thanks to all for your inputs - I now have this working.

The original idea was to copy selected models from one assembly into a new file specified by the user and maintain their positions and orientations relative to the assembly origin.

I haven't done this part as yet, but it will copy into the active assembly, which is OK for now, and lets me achieve what I need. I can attach a new assembly, edit that in place and copy the models into that.

I was amazed that it would do that without any additional code.

It even grounds the models. Smiley Very Happy

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Occurrence Position

Phenom
Phenom

Just come across a slight problem.

The transformation matrix that I get is for the part relative to its PARENT assembly origin.

This is OK if the active and parent origins are the same, but if not the part is placed incorrectly.

What I need is the part relative to the ACTIVE assembly origin.

Is this possible, or do I need to work up through each assembly level and 'add' the parent offsets until I reach my top level of assembly?

If I have in-place edited a sub-assembly I would then also need to work back down until I reach the active file.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.