iLogic - Open Drawing and Change View Scale

iLogic - Open Drawing and Change View Scale

Anonymous
Non applicable
656 Visites
3 Réponses
Message 1 sur 4

iLogic - Open Drawing and Change View Scale

Anonymous
Non 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 J'aime
Solutions acceptées (1)
657 Visites
3 Réponses
Replies (3)
Message 2 sur 4

Anonymous
Non 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 J'aime
Message 3 sur 4

Anonymous
Non applicable
Solution acceptée

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 J'aime
Message 4 sur 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 J'aime