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.
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