• Blog posts


    By Luke Davenport


    You need to quickly take a copy of an assembly and its associated drawing file 


    There are loads of ways to copy an Inventor design. I often point people to this great blog by Paul Munford as a first port of call.


    However the scenario I’m concerned with here is quite specific. We have a simple Inventor assembly and drawing, where the following is true: 

    • The assembly only contains standard parts (not stretchable parts).
    • It is a single level assembly (with no sub-assemblies). If sub-assemblies are included, they would also need to be standard assemblies, as they will not be copied by the rule, just reused. 

    So if you’ve got a scenario like this – carry on reading. If not……….sorry! 

    Still with me? In this scenario we have, we can create a new copy really quickly, without iLogic Copy Design, Vault, Design Assistant, or any of that stuff. This is because we can simply copy the top-level assembly, without needing to worry about the sub-assemblies and the parts they contain. Also we don’t need to copy the sub-parts, as they are all library parts, and can simply be replaced with other library parts in the copied design if required (they don’t need to be modified in any way, so they don’t need to be independent copies). 

    So now without iLogic we could take the model and drawing and manually do the following: 

    • Do a ‘Save As’ on the assembly model
    • Open the drawing and do a ‘Save As’ on it
    • Use ‘Manage -> Replace Model Reference’ to point the drawing to the newly copied assembly. 

    Not too complicated is it? But it can certainly get pretty tiresome when you have to do it a few times every day. Worth a quick bit of iLogic to automate? 

    So the iLogic code below needs pasting into a rule in the assembly model file, and it will do the following:

    • Check that a drawing file exists in the same folder as the assembly model, with the same name as the assembly model. Note that the code is currently looking for .dwg drawing files – change this to .idw if you insist on using .idw drawings J)
    • Ask the user for a Job Number suffix for the new filenames (for model and drawing)
    • Perform a ‘Save As’ of the assembly model
    • Open the drawing (if it isn’t already open)
    • Save a copy of the drawing
    • Point the new drawing to the new assembly
    • Make the new copied assembly model active
    • Job done! 

    Download the code HERE

    By the way – if you want to modify the iLogic rule to work with a single part and its related drawing, this will be simple to do. Just change references to .iam to .ipt in the rule and that should get you there.

    Here’s a quick video showing the whole wonderful process in action:



  • Avatar
    Neal Bakker

    Hello Dave, how can i rename the whole file instead of the job number suffix?

    Comment actions Permalink
  • Avatar
    Zen Admin

    Hi Neal, try removing the Current filename details from the code.

    I've highlighted the bit you need to remove in this image:


    Comment actions Permalink
  • Avatar
    Neal Bakker

    Hello Clinton,

    Tnx for your reply
    I already tried that.
    When i do that i get the errror message:
    Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
    I used the .idw option

    The more info shows:
    System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
    at Inventor.Document.SaveAs(String FileName, Boolean SaveCopyAs)
    at LmiRuleScript.Main()
    at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
    at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

    Comment actions Permalink
  • 0
    Comment actions Permalink

Please sign in to leave a comment.