Inventor DWG to AutoCAD DWG

Inventor DWG to AutoCAD DWG

Jason.Rugg
Collaborator Collaborator
883 Views
8 Replies
Message 1 of 9

Inventor DWG to AutoCAD DWG

Jason.Rugg
Collaborator
Collaborator

Using LISP I have created code that takes an exported AutoCAD DWG (from Inventor DWG) and separates model geometry from annotation geometry and places each into their respective space (model space/paper space). The code also remaps layers and other company standards that normally get applied to AutoCAD drawings.

 

The problem I am having is with detail views that are scaled differently than the base view. The code takes the exported drawing and scales the two spaces accordingly so that everything in model space is 1:1 (except details) and in paper space scales borders/titleblocks/symbols/dimensions/text/etc. up or down to a certain size paper layout and then applies the correct dimension styling and scaling to make it all appear correctly.

 

Is there a way though code, lisp or ilogic, to isolate views/geometry that use a different scale from the base view and scale the geometry back to 1:1?

0 Likes
884 Views
8 Replies
Replies (8)
Message 2 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@Jason.Rugg,

 

Can you please provide non confidential model data to test the feasibility?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

Jason.Rugg
Collaborator
Collaborator

@chandra.shekar.gAny model would work for this, it does not have to be something specific to my line of work, even one of the sample models provided with the software would work. I have the code all figured out with the exception of how to detect and rescale non base view scale details automatically.

0 Likes
Message 4 of 9

YuhanZhang
Autodesk
Autodesk

Below is a VBA code sample to reset all the drawing views' scale to 1:1, maybe it can help you, you can open a drawing and run it in VBA:

 

Sub ResetDrawingViewScale()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    For Each oSheet In oDoc.Sheets
        Dim oDrawView As DrawingView
        For Each oDrawView In oSheet.DrawingViews
            If oDrawView.ParentView Is Nothing Then
                oDrawView.[Scale] = 1
            Else
                oDrawView.ScaleFromBase = True
            End If
        Next
     Next

End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 9

Jason.Rugg
Collaborator
Collaborator

@YuhanZhangI am not very good when it comes to coding. When I try to run the code you gave it errors out and says "Error in rule program format: The rule must contain: Sub Main() … End Sub"

0 Likes
Message 6 of 9

JamieVJohnson2
Collaborator
Collaborator

So the iLogic and VBA editors require you to have one of 2 conditions for code to work.

1.  All the code is of a single routine, and therefore, does not need to be properly grouped (Sub or Function with titles).

2.  The code is a construct of multiple routines each with a different name, and must have an entry point.

 

The computer is complaining about line 2.  Here your system is looking at a page of code, it see's named groups of code you call routines (Sub, or Function methods).  It is structured to look for Sub Main in that situation where you tell it where to start and what to do:

 

'Sub main is the entry point telling the system where to start running code

Sub Main

   Some setup code perhaps

   RunOtherSubOne

   RunOtherSubTwo

   Some cleanup code perhaps

End Sub

 

'RunOtherSubOne is a routine with a specific purpose

Public Sub RunOtherSubOne

   Do some cool stuff

   oWrench =  GetMeThatWrench(some object)

End Sub

 

'RunOtherSubTwo is a different routine with a different specific purpose

Public Sub RunOtherSubTwo

   Do some boring stuff

   oWrench =  GetMeThatWrench(some object)

End Sub

 

'GetMeThatWrench is a Function, because it returns an object, that is reused many times

Public Function GetMeThatWrench(object) as Wrench

    Find Wrench

    Return Wrench

End Function

 

The catch, If you place a single routine only in the editor, and it has a name such as Sub RunOtherSubOne, the editor will freak out because it is not called Sub Main.  Here you have two options, rename it to Sub Main (to fulfill condition 2), or remove the Sub Name header line and End Sub footer line (which falls back to condition 1).

 

Hope that helps,

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 7 of 9

YuhanZhang
Autodesk
Autodesk

Try below if you want to run in iLogic rule:

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisDoc.Document
    
    Dim oSheet As Sheet
    For Each oSheet In oDoc.Sheets
        Dim oDrawView As DrawingView
        For Each oDrawView In oSheet.DrawingViews
            If oDrawView.ParentView Is Nothing Then
                oDrawView.[Scale] = 1
            Else
                oDrawView.ScaleFromBase = True
            End If
        Next
     Next

End Sub


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 8 of 9

Jason.Rugg
Collaborator
Collaborator

@YuhanZhangSo this makes all views 1:1. What I need is for the code to leave the initial base view scale alone and any other view that is scaled differently from the base view to be scaled to the base view scale. Hope that makes sense. I have tried making it do that but I keep breaking the code. 

0 Likes
Message 9 of 9

YuhanZhang
Autodesk
Autodesk

Then you can just delete below line in the code sample:

 

oDrawView.[Scale] = 1

 

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes