Modify Sample VBA Code to change the sketch plane using sample code

Modify Sample VBA Code to change the sketch plane using sample code

Anonymous
Not applicable
859 Views
1 Reply
Message 1 of 2

Modify Sample VBA Code to change the sketch plane using sample code

Anonymous
Not applicable

Greetings,

I am getting started with Autodesk Inventor VBA and I hope this question is not a repeat!

I found a sample code from Autodesk Inventor Help Community composed of two subroutines where:

  • First Sub, CreateSketchBlockDefinition(), Defines a sketch block that is a rectangle of 4 cm x 3 cm.
  • Second Sub, InsertSketchBlockDefinition(), Inserts this sketch at with a corner at (10cm, 10cm) on the xy plane. 

Inventor 2020 Help: Create and insert a sketch block definition into a part sketch (autodesk.com)

 

I have the following questions:

  1. Is there a good way to learn AutoDesk VBA commands by recording them and seeing the command lines generated in VBA Editor? This is possible to do in Excel by clicking the record macro button. I don't see a record macro button in Autodesk Inventor.
  2. How can I modify the first subroutine , CreateSketchBlockDefinition(), to include fillets at the four corners of the rectangle?
  3. How can I modify the second subroutine,  InsertSketchBlockDefinition(), to create the sketch on a plane that is different from the xy plane? For example, I would like the sketch to be placed on the active plane or selected plane in Inventor. Most likely it will be to modify the line shown below:
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

But I am not sure how to set the plane to the selected plane in inventor.

 

Thanks!

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

JelteDeJong
Mentor
Mentor

Lets start with the first question. There is none macro recorder like you have in excel.  if you start learning Inventor automatization then i would advice you to start using iLogic instead of VBa. In iLogic you will be able to use iLogic objects (code) that make programming more easy. In VBa you will not have access to those objects. Also VBa is reaching end of life (or is already obsolete im not sure). It's not even installed any more by default with newer versions of Inventor. I could not find the post but in the last weeks the same question was asked and there are some good sites and youtube chanels out there.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes