How to draw rectangle in inventor through vba editor

How to draw rectangle in inventor through vba editor

Anonymous
Not applicable
820 Views
1 Reply
Message 1 of 2

How to draw rectangle in inventor through vba editor

Anonymous
Not applicable

How to draw rectangle in inventor through vba editor

0 Likes
821 Views
1 Reply
Reply (1)
Message 2 of 2

JamieVJohnson2
Collaborator
Collaborator

First get the application and document,

Then get the definition (is this a part file, assembly file, or drawing file, this question changes things a bit),

Next get a sketch (get one or create a new one)

Set the sketch to edit mode

Inside the sketch, create the rectangle (several methods inside of the sketch.sketchlines)

Optionally create the constraints to the rectangle

Exit sketch edit mode

Save your work.

 

Sub DrawRectangle()
    Dim invApp As Inventor.Application
    invApp = ThisApplication
    Dim doc As Inventor.Document
    doc = invApp.ActiveDocument
    Dim cDef As ComponentDefinition
    cDef = doc.Definition
    Dim sketch As Inventor.sketch
    sketch = cDef.Sketches
    sketch.Edit
    Dim point1 As Point2d
    point1 = invApp.TransientGeometry.CreatePoint2d(0, 0)
    Dim point2 As Point2d
    point2 = invApp.TransientGeometry.CreatePoint2d(1, 1)
    Dim see As Object
    see = sketch.SketchLines.AddAsTwoPointRectangle(point1, point2)
    sketch.ExitEdit
    doc.Save
End Sub
Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/