Inventor Customization

Inventor Customization

Valued Contributor
Posts: 68
Registered: ‎03-23-2012
Message 1 of 2 (171 Views)

How Does Inventor Name Views or Sketch Views for VB?

171 Views, 1 Replies
01-08-2013 11:20 AM

Using Inv 2013 and VB 2010.  I am trying to reference a sketch within a drawing view, but I am having a hard time figuring out which view number and sketch number to use.  I thought I had it figured out, but apparently I was wrong.


For example, see the 2 attached pics, Drawing A and Drawing B.  For Drawing A I had the sketch reference set as

Dim oSheet1_View As DrawingView = oDrawDoc.Sheets(1).DrawingViews(3)
        Dim oSketch As DrawingSketch
        oSketch = oSheet1_View.Sketches.Item(1)

 Drawing View 3, as it was the 3rd Drawing View in the list, and Sketch #1 within that Drawing View.  I thought this was how it worked, because it worked with my code and it hid the sketch.  However, moving on to Drawing B, I used the same code, and it does not reference that sketch at all.  It did nothing to it.  Even though the Flange_Holes sketch is in the same position.  3rd View down the list, 1st sketch.


So how does Inventor reference these views and sketches?  Is it in order of creation?  Is there a way to reference it by the what the sketch is named instead of trying to decipher the number it's assigned?  I have a lot of drawings already made, and I'm not positive the views were taken and created in the same exact order each time.


Any help is appreciated, thanks.



ADN Support Specialist
Posts: 676
Registered: ‎06-02-2009
Message 2 of 2 (152 Views)

Re: How Does Inventor Name Views or Sketch Views for VB?

01-14-2013 01:08 AM in reply to: nickv02

Hi There,


Some collections support selection by index and by name, simply look at the help files if the Item method takes a variant as input, for example the "DrawingSketches.Item" method has the following comments:


"Input Variant value that specifies the to return. This can be either a numeric value indicating the index of the item in the collection or it can be a string indicating the sketch name. If an out of range index or a name of a non-existent sketch is specified, an error occurs."
In case the collection doesn't support indexing by name, the safest way is to iterate through all elements using index 1 to Count and check the "Name" property of each element.
I hope it helps.

Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.