• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Member
    Posts: 5
    Registered: ‎04-20-2010
    Accepted Solution

    iLogic Save As (dwg) if file is idw

    266 Views, 4 Replies
    01-03-2013 08:09 AM

    hello friends

    I made a rule to save as dwg.

     

        ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".dwg"),True)
        MessageBox.Show(ThisDoc.FileName(False)& ".dwg  Saved!! " & vbCrLf & vbCrLf & ThisDoc.Path , "Save As")
    

     

    I wonder if it is possible to implement this rule, so it is executed only if you are saving a file in IDW

    .
    If the file to be saved is a ipt, for example, do not run the save as.

    That is, the question is how to know the extension of the newly saved file to test the rule save as?

     

    thank you for your attention

    Marcus Roberto Jung
    Mechanical Engineer / / Porto Alegre / / Brazil

    Inventor Pro 2013
    Intel Core i7 12GB RAM
    Windows 7 - 64bits
    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,988
    Registered: ‎03-08-2006

    Re: iLogic Save As (dwg) if file is idw

    01-03-2013 08:36 AM in reply to: mjtubos

    Hi mjtubos,

     

    This should work:

     

     

     'check file type
    If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
    MessageBox.Show("This file is not a drawing file.", "iLogic")
    Else
    ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".dwg"),True)
    MessageBox.Show(ThisDoc.FileName(False)& ".dwg  Saved!! " & vbCrLf & vbCrLf & ThisDoc.Path , "Save As")
    End If

     I hope this helps.
    Best of luck to you in all of your Inventor pursuits,
    Curtis
    http://inventortrenches.blogspot.com



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎04-20-2010

    Re: iLogic Save As (dwg) if file is idw

    01-03-2013 09:15 AM in reply to: Curtis_Waguespack

    Dear Curtis

     

    Thanks for the prompt solution of my question.

    I implemented this code, saving the DWG document in a new directory. I do not know if it would be the best solution, but it worked.

     

    greetings

     

    Marcus Jung

     

     

    Dim odoc As Document
    
    oDoc = ThisApplication.ActiveDocument
    
    Dim assemblyPath As String = "E:\Desenhos Marcus\Inventor\_newdir"
    Dim assemblyFileName As String = System.IO.Path.GetFileName(oDoc.FullFileName)
    Dim assemblyFileNameNoExt As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
    Dim driverPathAndFileName = assemblyPath + "\" + assemblyFileNameNoExt + ".dwg"
    
    
    
    If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
        MessageBox.Show("This file is not a drawing file.", "iLogic")
    Else
        ThisDoc.Document.SaveAs(driverPathAndFileName , True)
        MessageBox.Show(ThisDoc.FileName(False)& ".dwg  Saved!!! " & vbCrLf & vbCrLf & assemblyPath , "Save As")
    End If
    
    
    Marcus Roberto Jung
    Mechanical Engineer / / Porto Alegre / / Brazil

    Inventor Pro 2013
    Intel Core i7 12GB RAM
    Windows 7 - 64bits
    Please use plain text.
    Valued Mentor
    swordmaster
    Posts: 453
    Registered: ‎12-15-2008

    Re: iLogic Save As (dwg) if file is idw

    01-03-2013 01:32 PM in reply to: mjtubos

    there are two types of .dwg in inventor (at least in INV2009)

    Autodesk Inventor drawings

    AutoCad drawings

     

    which type will be created by running the code posted?

    Inventor 2010 Certified Professional
    Please use plain text.
    Member
    Posts: 5
    Registered: ‎04-20-2010

    Re: iLogic Save As (dwg) if file is idw

    01-04-2013 03:30 AM in reply to: swordmaster

    hello

     

    to run the rule above, the file is saved in dwg format Autocad 2007 Drawing.


    But that is because I had previously set up by the "Save copy as"  the file version for Autocad 2007 Drawing.

    Also I wonder if it is possible to do this configuration file version by iLogic code

     

    best regards

    Marcus Roberto Jung
    Mechanical Engineer / / Porto Alegre / / Brazil

    Inventor Pro 2013
    Intel Core i7 12GB RAM
    Windows 7 - 64bits
    Please use plain text.