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: 

Resolve drawing to part with same filename

10 REPLIES 10
Reply
Message 1 of 11
PeterKingma
799 Views, 10 Replies

Resolve drawing to part with same filename

Why doesn't Inventor has an option where you can prefere to resolve the drawing to a part with the same filename? I've been looking on the web for a solution to this problem but are not able to find something suitable.
Maybe OnFileResolution might work but I have posted that befor and got no reply. Does anyone know how that works and if it's the solution. Or is there a third party solution prehaps?

We want to open multiple drawings at once, where all drawings are automaticaly resolved to the parts with the same filename. ( Part001.idw resolve to Part001.ipt etc.)

Thanks in advance.
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: PeterKingma

The OnFileResolution event will allow you to do this. You'll need to write
an Add-In that watches for this event and whenever a drawing is being opened
it would respond to it by providing the filename of the part you want.

This event is fired whenever Inventor needs to find a file on disk. One
case is where you open a drawing and it needs to find the file(s) the
drawing references. The event fires before Inventor does any file
resolution. If you respond to the event and provide the filename then
Inventor will use that file and skip its standard file resolution. This
allows you to replace Inventor's file resolution rules with your own.
--
Brian Ekins
Autodesk Inventor API Product Designer
http://blogs.autodesk.com/modthemachine

"PeterKingma" wrote in message news:6210113@discussion.autodesk.com...
Why doesn't Inventor has an option where you can prefere to resolve the
drawing to a part with the same filename? I've been looking on the web for a
solution to this problem but are not able to find something suitable.
Maybe OnFileResolution might work but I have posted that befor and got no
reply. Does anyone know how that works and if it's the solution. Or is there
a third party solution prehaps?

We want to open multiple drawings at once, where all drawings are
automaticaly resolved to the parts with the same filename. ( Part001.idw
resolve to Part001.ipt etc.)

Thanks in advance.
Message 3 of 11

I'm not sure what you're wanting to accomplish.

Will you have a number of parts open, and you want to push a button to open all of their drawings? Are you wanting to create new drawings? Are you wanting to open a number of drawing files and change the file reference to different parts?

I'm pretty sure you'd only use OnFileResolution if you knew a relative file path was going to be wrong, and you wanted to instead point to a different location (like on a network or something).
Message 4 of 11
PeterKingma
in reply to: PeterKingma

Hello, Thanks for your quick reply,

We have lots of small projects, which have parts we copy paste from a central library. These library parts have drawings already linked to them, and we copy paste the drawings along with these parts. For each project all parts and drawings are being renamed so we know to which project each part belongs. Then during the design of the assemblies, these parts are al being made adaptive and will change there shape. (I've written a macro for this already, to enable and disable adaptivity for multiple parts at once.) After our customer gives approval, all drawings have to be printed for our workshop. Now Inventor let us open multiple drawings at once, but then we cannot resolve the link to the parts, as these were al renamed!
So... we know the exact locations of all the parts (also for macro-code) ... and we know that the filename of a part is the same as the filename of the drawing it should resolve to.
Now, we would like to open all these drawings at once and inventor will automaticaly link each drawing to the correct part.

It is great to hear that the OnFileResolution can be very usefull for this. Is it possible to give a small example as the help in inventor of this event is very limited. And... I'm not familiar with events!


Thanks in advance!
Message 5 of 11
cadfish1
in reply to: PeterKingma

Attached is a macro that will find relocated Content Center model (fasteners). At one point in time, our engineers would reference Content Center models on the C drive and in project specific folders on the network depending on the project. As they evolved they want to share files and so it was necessary to centralize Content Center. Once centralized they copied the Content Center models on the C drive and in project specific folders on the network to the new centralized location on the network. The problem is, even though the Content Center models have been moved to the new centralized location, the assemblies using these models haven't been opened since the move. That's where the attached macro comes in. You execute the LocateMissingContentCenterFiles subroutine which instances and initializes a Class (clsEventsCC) containing the OnFileResolution event procedure. Once in memory, all the user has to do is open assemblies and the OnFileResolution event procedure will find the relocated Content Center models. Once the assembly is fully resolved, it should be saved (and any change subs) by the user so that the assembly(s) remembers the new locations of the Content Center models. The macro will stay in memory until Inventor to shut down which mean the user can repair a countless amount of assemblies by only launching the LocateMissingContentCenterFiles subroutine once. The most efficient way to repair all the subs in a project is to open the top level assembly(s), that way all subs beneath it are repaired.
Message 6 of 11
PeterKingma
in reply to: PeterKingma

Thanks Cadfish1 for your macro.

It will take me a while though to figure out the basics. I have no experience with events and class modules. I'll dig into the code you send and try to find the main code for this event. (We definitely not need THAT much code.)
When I have figured it out, I'll post my code back.

Any help in the meantime will be appreciated.
Thanks.
Message 7 of 11
cadfish1
in reply to: PeterKingma

How do you foresee when to use your OnResolution event procedure? Meaning, do you want it to always be in memory or just when you need it? If you need it always in memory then create an addin but it sounds like you need it only when you're producing the copy & renaming. In this case a macro works well because you load it when you need it. Once load in memory, the macro continues to work until you shut Inventor down. So, once you are done do copy & renaming, you should shut Inventor down so the macro is dumped out of memory so it would effect the normal Inventor environment (no copy & renaming). There may be a way of unloading the OnResolution event procedure but I’m not aware of a way. If you copy & renaming a lot, you might want to consider creating an addin so you can add a button to the menu system in order to load & launch the macro with easy. I could help you off-line with that if you'd like.

Do I understand the situation? You have files A.IDW and A.IPT (where A.IDW references A.IPT via a View) and you want to copy these files as B.IDW and B.IPT. When you open B.IDW you want it to resolve to B.IPT (not A.IPT). If my understanding is correct here’s what I would do. Create main macro/form that requests/supplies what part number (drawing & model) from what path to copy and what the new part number (file name) will be and I’m guessing the path for the copied files as well. Upon pressing the Go button the main macro would first copy/rename file (you can use FileCopy to rename as it copies), create a Public variable containing ‘path/new part number.ipt’, load your OnResolution event procedure then opens the copies/renamed drawing. The OnResolution event procedure looking before resolution (i.e. an IF expression where BeforeOrAfter = Inventor.EventTimingEnum.kBefore) would use the Public variables ‘path/new part number.ipt’ to revolve (B.IPT) by setting FullFileName = Public variables ‘path/new part number.ipt’and HandlingCode = Inventor.HandlingCodeEnum.kEventHandled

If you also create a Public variable for the ‘path/new part number.idw’ you could have the OnResolution event procedure also look at after resolution so you could instruct it to connect to the drawing object for the purpose of saving it.
Message 8 of 11
PeterKingma
in reply to: PeterKingma

Our best option is to have it alway's in memory when inventor launches. Almost every project has this part name - drawing name configuration. The copy pasting is done by the windows explorer. We do belief this still is the fastest solution. All our projects are one manned. So.. no vault, no parts loggin in or loggin out, no keeping up "who did which revision" (we only have two engineers). Just using a fixed library directory with subdirs, and with a nice and simple naming code, library parts can easily be found, added or changed. (Customer requirements do change a lot.)

- make projectfolder B with project B.ipj
- make new B.iam
- copy past A.ipt and A.idw from the library into the projectfolder (can be up to 50 different parts per assembly)
- rename part A.ipt and A.idw to B.ipt and B.idw
- change the shape of part B.ipt by adaptivity in the B.iam
- * link B.idw to B.ipt
- print B.idw

The printing bit I've already done by writing a macro that prints all visible idw's at once.

So.. In my opinion an Add-in which when opening B.idw, it links it not to A.ipt, but to B.ipt (which sits in the same dir, but looking throughout the workspace would also be a great option, when in the future we should deside to copy the drawings into a different subdir). And if file not found, inventors native resolution can be used instead. This way, you wouldn't notice the custom resolution. It simly does it's job when needed. (This could be a nice option for autodesk to implement into next releases.)

If you can help off-line with the easy load & launch part, that of course would be appreciated a lot! Thanks

The copy & renaming, we can skip, as this is way to complex to do by macro. That's what I mend by "We definitely not need THAT much code." It also has to work when multiple idw's are opened at once! Else we still need to open the drawings one by one.
Message 9 of 11
cadfish1
in reply to: PeterKingma

I have created a macro that will do what you want but you’ll have to load the project (attached file) and run the macro (Copy_Rename_Resolve). I did it as a macro because of quick development. As you know, you’ll need to create an addin so your OnFileResolution event procedure is automcatically loaded when Inventor is launched. What development environment (IDE) will you create your addin (VB or VB.NET & what version)? You won’t need me to show you how to make a menu button for the purpose of launching the macro containing your OnFileResolution event procedure because you want OnFileResolution to automatically load when Inventor is launched. However I can help you a bit if you’d like to know how to make a menu button and/or launch a macro from that button. If so let’s take that off-line (what’s your email address?).

I did construct the OnFileResolution event procedure in such a way that will allow it to MOST LIKELY not interfere with regular file resolution. Regular, meaning when you are NOT doing the copy/paste/resolve. I’m specifically looking to see if the missing file is an IPT and if the referencing document is a drawing, if so then I look to see if a IPT with the same file name (before file extension) and same path exists, if so it resolves the IPT. The premise is, A.ipt cannot be in the same folder as B.idw otherwise A.ipt will be resolved instead of B.ipt.

I also added another event to save the drawing if and only if the copy/paste/resolve resolution occurred.

Also, I’ve attached a modified version of the EventWatcher.exe (an Autodesk SDK sample). This is a handy app for learning events and seeing a list on events on one place, sorted by type then name. The only modification I made is the addition of a Check All button to make it easy to listen to all events.
Message 10 of 11
PeterKingma
in reply to: PeterKingma

Hello Cadfish1,

Sorry for my late reply, I was a few day's off. But thanks a lot, it's working very well! This will save us a substantial amount of time with our produkt drawings.

To not make this thread any longer than necessary, below my email to go off- line.
pete_stro@hotmail.com Edited by: PeterKingma on Jul 6, 2009 10:35 AM
Message 11 of 11
naresh_kalyan
in reply to: PeterKingma

hi Everyone,

I'm trying to do this in vb.net. I need to create an Addin for this. oh, yes I could able to see the addin template in vb.net templates.

Now,I have not understood the process of using this template. Can anyone help me on this?

 

thanks in advance.

 

Regards

NKalyan

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

Post to forums  

Autodesk Design & Make Report