Creating workpoints from the vertex of a part[VBA]

Creating workpoints from the vertex of a part[VBA]

Anonymous
Not applicable
534 Views
3 Replies
Message 1 of 4

Creating workpoints from the vertex of a part[VBA]

Anonymous
Not applicable

Im trying to create an array of workpoints based on the vertex of a part. I want to create the workpoints with coordinates based on the part and not the coordinates from the main frame. I tried using this, 

Dim wp As workpoint
Set wp = partDef.WorkPoints.AddFixed(ThisApplication.TransientGeometry.CreatePoint(0, 0, 1))

 

But, this just creates the point in space. Is there anyway to code it to accept the vertex from the user and create it based on that?

 

Thanks

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

Xun.Zhang
Alumni
Alumni
Accepted solution

Hi,

 

Firstly, you have to get the property of that point with VBA based on a projection of 2D sketch, and than you can create workpoint based on that point.

 

Here is a sample for your reference.

Dim oApp As Inventor.Application
Set oApp = ThisApplication

Dim oPartDoc As PartDocument
Set oPartDoc = oApp.Documents.Add(kPartDocumentObject, _
   oApp.GetTemplateFile(kPartDocumentObject))

Dim oSketch As PlanarSketch
Set oSketch = oPartDoc.ComponentDefinition.Sketches.Add _
  (oPartDoc.ComponentDefinition.WorkPlanes.Item(3))
 
Dim oTG As TransientGeometry
Set oTG = oApp.TransientGeometry

Dim oSkPnts As SketchPoints
Set oSkPnts = oSketch.SketchPoints
Call oSkPnts.Add(oTG.CreatePoint2d(10, 20), False)

Xun
0 Likes
Message 3 of 4

dgreatice
Collaborator
Collaborator

please provide screenshot or attachments to help another.

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 4

Anonymous
Not applicable

Awesome I think this should work. Thanks a lot!!

0 Likes