Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketch Orientation in VB.net

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dano0310
1452 Views, 4 Replies

Sketch Orientation in VB.net

Hi Just wondering if anyone can answer my stupid question.  I am just wondering how to change the orientation of a sketch in VB.net.  I have no worries in VBA but the command to set the orientation and origin don't seem to work in VB.net.

If someone can help me sort out this little query I would be greatly appreciative.

Regards

Dan

4 REPLIES 4
Message 2 of 5
ALink
in reply to: dano0310

Could you please post your VBA code?

Message 3 of 5
dano0310
in reply to: dano0310

Hi ALink

Thanks for your time.   Below is the VBA code I am trying to get working in VB.net.  Basically it is nearlly identical to a sample I found somewhere.

 

' Set the origin point to use the center point work point.

oSketch.OriginPoint = oPartCompdef.WorkPoints.Item(1)

 

' Set the axis to to the Y axis oSketch.

AxisEntity = oPartCompdef.WorkAxes(2)

 

Cheers

Dan

Message 4 of 5
ekinsb
in reply to: dano0310

These functions provide similar functionality as the "Edit Coordinate System" command that you access by right-clicking on a sketch in the browser.  Below is some sample code that creates a part with a sketch and then uses the properties to reorient the sketch.

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    Dim invApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
    Dim partDoc As Inventor.PartDocument = invApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, _
                                           invApp.FileManager.GetTemplateFile(Inventor.DocumentTypeEnum.kPartDocumentObject))
    Dim partDef As Inventor.PartComponentDefinition = partDoc.ComponentDefinition
    Dim tg As Inventor.TransientGeometry = invApp.TransientGeometry

    ' Create a work point in space.
    Dim wp As Inventor.WorkPoint = partDef.WorkPoints.AddFixed(tg.CreatePoint(5, 2, 3))

    ' Create a sketch on the X-Y work plane.
    Dim sketch As Inventor.PlanarSketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(3))

    ' Draw a line in the X direction on the sketch.
    sketch.SketchLines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(5, 0))

    ' Set the axis entity to be the Y work axis.
    sketch.AxisEntity = partDef.WorkAxes.Item(2)
    sketch.OriginPoint = wp
End Sub

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 5
dano0310
in reply to: dano0310

Thanks Brian

The only thing I had wrong was that I had my sketch as a sketch instead of a planarsketch.  VB.net is a lot less forgiving than VBA.

Thanks again

Dan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report