iLogic - Open Drawing and Change View Scale

iLogic - Open Drawing and Change View Scale

Anonymous
Not applicable
648 Views
3 Replies
Message 1 of 4

iLogic - Open Drawing and Change View Scale

Anonymous
Not applicable

Hello,

 

I have been searching for awhile on a solution for this. I am running a bit of code that will take an assembly and save a drawing based on a template drawing.

 

The assembly is open and when running the code it searches for the template drawing opens it in the background, and then replaces the drawing references and saves as a new drawing. While this is happening, I would like to change the scale of the views depending on the overall length of the assembly. I cannot seem to get this to work as most of the code I keep coming up with is below, but this only applies if the drawing is the active document, which it is not. Is there a way to scale the drawing views from the assembly while everything is running in the background?

ActiveSheet.View("VIEW1").Scale = 0.15
0 Likes
Accepted solutions (1)
649 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Here is a little more specifics of my code:

Dim oDoc As AssemblyDocument 
oDoc = ThisApplication.ActiveDocument
Dim oComps As ComponentOccurrences 
oComps = oDoc.ComponentDefinition.Occurrences

Dim oDrawDoc As DrawingDocument
		
        Try
            oDrawDoc = ThisApplication.Documents.Open(oMotherPath & AssyMother & ".idw", True) 
        Catch
            oDrawDoc = ThisApplication.Documents.Open(oMotherPath & AssyMother & ".dwg", True)       
        End Try

	oDrawDoc.Activate
		
	ActiveSheet.View("VIEW6").Scale = 0.15

        oDrawDoc.Update
        oDrawDoc.SaveAsInventorDWG(oMemberPath & AssyMember & ".dwg", True)
        oDrawDoc.Close()

 I am not sure why oDrawDoc.Activate does not work, but oDrawDoc.SaveAsInventorDWG and oDrawDoc.Close does. Is it not possible to activate this drawing?

0 Likes
Message 3 of 4

Anonymous
Not applicable
Accepted solution

I was able to get it to work with this, if anyone ever needs something similar.

 

  Dim oSheet As Sheet = oDrawDoc.ActiveSheet

  Dim oView As DrawingView = oSheet.DrawingViews.Item(2)
  Dim oViews As DrawingViews = oSheet.DrawingViews
  Dim oScale As Double
 
  oView.Scale = 0.15
0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Glad to know that you have found a solution. 

 

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes