Position of the origin of a part within an assembly (Solidworks API)

Hello

I look within a VBA macro launched in an assembly to retrieve to place in an excel spreadsheet the name of the part (it's done) and the coordinates of the origin of this part in this assembly. That's what I don't know how to do yet.

Here is the piece of code concerned:

ChildPartCount = UBound(AssChild)    

    For j = 0 To ChildPartCount
            'Name and config
            xlapp. Worksheets(1).cells(Row, 1). Value = AssChild(j). Name
            xlapp. Worksheets(1).cells(Row, 2). Value = AssChild(j). ????

           Line=Line+1

          Next

Thanks in advance to whoever can help me

Hello

 

I don't understand why you are trying to have the position of the origins. The components of the assembly I understand but the position of the origin seems a little too theoretical to me.

 

Especially since you're going to have the position of the origin but not the direction of the axes. You can surely find the answer here:

http://help.solidworks.com/2018/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.isketchpoint~getid.html?verRedirect=1

 

I've done something like this, I've made a sketch with reference point positions, I'm managing the position of the points and I'm saying this component goes on this point.

I confirm that I need the coordinates of the origin, without the axes. ^^

I was unable to use the GetID for the origin. I feel like you need to have a sketch.

But I ended up finding the right syntax, if anyone has the same need, namely: 

AssChild(j). Transform2.ArrayData(9)   (to be multiplied by 1000) for the x-coordinate

for the y ArrayData(10) and (11) for the z.

Thank you for your contribution Mandragore.

1 Like

That's the problem with my link, he looks for the coordinates of the point in the sketch.

 

I just went to the workshop and I was asked exactly the same .... namely to retrieve the position on Y of certain components in an assembly.

 

 

1 Like