[VBA] Creating a WorkPoint?

[VBA] Creating a WorkPoint?

Anonymous
Not applicable
3,775 Views
4 Replies
Message 1 of 5

[VBA] Creating a WorkPoint?

Anonymous
Not applicable

Simple question: How do you add a WorkPoint in an Assembly? 

 

I was hoping to find something like:

 

dim pt as new point ( 0, 0, 1)

oPartDef1.workpoints.add(pt)
   ~OR~

dim pt as point

pt.setlocation(0,0,1)

oPartDef1.workpoints.add(pt)

   ~OR~

dim pt as workpoint

set pt = oPartDef1.workpoints.addPoint(0,0,1)

 

It seems like I need to make a geometry (i.e. thisApplicaiton.TransientGeometry.CreatePoint(0,0,0) ) but I cannot find this feature for a componentOccurence.  I don't want to make a "Global" point, I want to make a point "Local" to a particualar part.

 

Thank you,

-Kenny

0 Likes
Accepted solutions (1)
3,776 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni

To create a work point in an assembly use the AddFixed method.  Work points in an assembly aren't really intelligent but just exist at a location in space.  Assembly constraints placed to the work point are used to define its position.  You can see this in the user interface if you create a work point and then look at in the browser to see the constraints that were created on it to define the intended behavior.  Using the API you have to these same steps yourself; create the work point and then add the constraints.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 5

Anonymous
Not applicable

ekinsb,

 

I've ran accross AddFixed and that works just fine if I have an existing point I just want to add.  However, I want to define a point from scratch and I was hoping that there was going to be a .AddFixed(x,y,z), but that didn't work.  I understand Why it doesn't work, but I have been unable to find a way to create a point before throwing it in the AddFixed method.

 

Or are you saying that I am only able to specify the correct coordinantes after I call the AddFixed Method?

 

-lemensk

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni
Accepted solution

AddFixed does take in an XYZ coordinate, it's just that the coordinate is passed as a Point object.  To do what you want you would do.

 

Dim wp As WorkPoint

Set wp = oPartDef.WorkPoints.AddFixed(ThisApplication.TransientGeometry.CreatePoint(0,0,1))


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 5

Anonymous
Not applicable

Thank you Brian,

 

I was hoping for a more condense statement, but I guess that this is as good as it gets. 

Note to others, to delete a workpoint: wp.Delete

 

-Kenny

0 Likes