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: 

Find related drawing using VBA

5 REPLIES 5
Reply
Message 1 of 6
bshbsh
919 Views, 5 Replies

Find related drawing using VBA

Hello,

 

I'm trying to write a VBA macro (for Inventor 2010) that would have to work on drawing .idw files that are generated from a given component.

So when I have an open assembly document, I want to go through all component occurences and work with the associated drawing.

There's a built in command in Inventor for that, in the context menu, something like "Open drawing" (mine is german, so not sure how it's called in english), which does this. It opens the drawing of the given part. From this I assumed, there must be a reference within each part, that points to the referencing drawing.

But I'm not able to find this information anywhere within the properties/objects of any component.

Could someone please show me how or where can I get this information out of the components? Using VBA.

 

Thanks in advance.

bsh

 

5 REPLIES 5
Message 2 of 6
Vladimir.Ananyev
in reply to: bshbsh

In general your model document doesn’t contain references to the associated drawings if they are not already in memory.

So you may search project folde and subfolders for idw files, open them in invisible mode, and check DrawingDocument.ReferencedDocumentDescriptors or DrawingDocument.ReferencedDocument collections for the references to your model file or document.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 6
bshbsh
in reply to: Vladimir.Ananyev

Thank you for the reply.

Fortunatelly I have a better way of doing this in our working environment, but my method is not 100% accurate, mostly because of user errors and some other rare circumstances. But the "Open drawing..." method via the GUI seems to work 100%, so I would love to know how it is doing it.

But as you say, there's no references in the model.

So I'm really wondering how it still works. I can't believe it is searching through and opening lots of drawings invisible, becaus it opens the drawing at once. It even finds the (original) drawing if I copy the part from outside of the project paths, modify and rename it, and the original drawing is outside of the project paths. This is what made me think that there must be some sort of reference in the model itself, somewhere, somehow.

Message 4 of 6
jdkriek
in reply to: bshbsh

The "Open drawing" via the UI is simply looking at the Model filename/part number and appending .IDW to it.

 

You can see this if you name your drawing something diffrent than the model for example

 

Model: T-025-80001.IAM

Drawing T-025-80001_opps.IDW

 

It will say it can't find the drawing reguardless if the model is in the drawing or not.

 

opendrawingexample.PNG

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 6
bshbsh
in reply to: jdkriek

(deleted previous post to add more explanation)

 

Here's an example:

Tehre's and old ProjectA, and PartA.ipt + PartA.idw in it.

I want to re-use PartA, slightly modified, in a new ProjectB. So I copy PartA.ipt into ProjectB folders, rename it to PartB.ipt and modify it.

When I click "open drawing", it opens the old PartA.idw, which wass not copied over, and is still in ProjectA, which is not part of ProjectB. (So there must be some direct path reference to this, otherwise it would not find it, since it's not in ProjectB search paths.)

I save the drawing as PartB.idw into ProjectB, replace the reference with PartB.ipt and update the drawing and save. From here on, when clicking "open drawing..." on PartB within ProjectB, it will open PartB.idw.

Strange but this is how it works for me.

Message 6 of 6
jdkriek
in reply to: bshbsh

I am definately not seeing that at all. 

 

As soon as I move PartA to ProjectB it looks for the drawing in ProjectB (wherever the part is)

 

Tested with 2011-2013 and got the same result. What method are you using to rename/copy? 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums