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: 

How to enable Construction mode with VB API?

7 REPLIES 7
Reply
Message 1 of 8
mucip
391 Views, 7 Replies

How to enable Construction mode with VB API?

Hi,

I'm using VB Express 2010 and Inventor 2013. I want enable/disable construction mode in sketch plane inner API program... How?...

 

Regards,

Mucip:)

7 REPLIES 7
Message 2 of 8
YuhanZhang
in reply to: mucip

To set the Construction to a sketch entity you can use SketchEntity.Construction property, a sample VB code snippet can be like below:

 

'say you have the oSketch assigned with a planar sketch
Dim oSketchLine As SketchLine
oSketchLine = oSketch.SketchLines.Item(1)
oSketchLine.Construction = True

 

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 8
mucip
in reply to: YuhanZhang

Dear Yuhanzhang,

Thanks a lot.

 

My code like below,

 

 rectangleLines = sk.SketchLines.AddAsTwoPointRectangle( _
                                    tg.CreatePoint2d(CerceveIlkX, CerceveIlkY), _
                                    tg.CreatePoint2d(CerceveIlkX + CerceveXMesafe, CerceveIlkY + CerceveYMesafe))

 

And I added blow code to make rectangule in construction mode,

 

 rectangleLines.Item(1).Construction = True

 rectangleLines.Item(2).Construction = True

 rectangleLines.Item(3).Construction = True

 rectangleLines.Item(4).Construction = True

 

 

But in any case I wanted to enable construction mode like I pressed contruction button on format section in ribbon bar... This will be much easier if posssible...

 

Regards,

Mucip:)

Message 4 of 8
YuhanZhang
in reply to: mucip

You can call the command definition to toggle the Construction mode, sample VBA code is like below:

 

Sub ToggleSketchConstruction()

ThisApplication.CommandManager.ControlDefinitions.Item("SketchConstructionCmd").Execute
    
End Sub

 Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 8
mucip
in reply to: YuhanZhang

Dear YuhanZhang,

That's what I need exactly but I couldn't get any solution with the below my code in VB-2010 Express:

 

 

Form1.inv_App.CommandManager.ControlDefinitions.Item("SketchConstructionCmd").Execute()

 

Regards,

Mucip:)

 

 

Message 6 of 8
YuhanZhang
in reply to: mucip

Did it raise any error? And can you make sure you call this method when a planar sketch is in edit mode? 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 8
mucip
in reply to: YuhanZhang

Hi,

Your code is working actually. When I run your code seperately in Button_click procedure it works and contruction button become active. But when I run your code between my code like below than code is not working. With below code it's expected that first line and arc normal and second line and arc is in construction mode. But after the code all line and arcs are normal (not construction!) and after the below code construction button becomes active... Very interesting... I think we need to some update or delay command after "construction mode activation" code part?!...

 

 

 

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

        Dim sk As PlanarSketch
        sk = Form1.inv_App.ActiveEditObject


        Dim tg As TransientGeometry
        tg = Form1.inv_App.TransientGeometry

        Dim line1 As SketchLine
        Dim arc1 As SketchArc
        Dim line2 As SketchLine
        Dim arc2 As SketchArc
        line1 = sk.SketchLines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(10, 0))
        arc1 = sk.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(10, 2), line1.EndSketchPoint, tg.CreatePoint2d(10, 4))

        ' Bu kısım yardımcı çizgi modunu açmak için...
        Form1.inv_App.CommandManager.ControlDefinitions.Item("SketchConstructionCmd").Execute()

        line2 = sk.SketchLines.AddByTwoPoints(arc1.EndSketchPoint, tg.CreatePoint2d(0, 4))
        arc2 = sk.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(0, 2), line2.EndSketchPoint, line1.StartSketchPoint)

    End Sub

 

Regards,

Mucip:)

Message 8 of 8
YuhanZhang
in reply to: mucip

I tried you code here and see the same problem. This should be an API bug that even the Construction mode is on the sketch entities created by API  are still normal. Seems now the workaround is to set the Construction property for each sketch entity.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report