Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Changing View Scale

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1951 Views, 4 Replies

iLogic Changing View Scale

Hello, I have a code snippet here, and i was wondering if i can use this to only change one certian view scale and not mess with the other scales?

 

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 6555 StartFragment: 314 EndFragment: 6523 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oSheets As Sheets
Dim oView As DrawingView
Dim oViews As DrawingViews
Dim oScale As Double

oSheets = oDrawDoc.Sheets
For Each oSheet In oSheets
   oViews = oSheet.DrawingViews
   For Each oView In oViews
oScale = InputBox("Enter Desired Scale", "Scaler", "1")
    
       If oView.ScaleFromBase = False Then
           oView.Scale = oScale
       End If
   Next
Next
Tags (3)
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

You can, however, if the number of views will always change, then you will have to be a little more creative and create a counter or something.

You need to know how to interrogate the model which you can find at the blog modthemachine.

 

The code that follows allows you to interrogate the object follows.

dim whatever document you are using, drawing, part, or assembly.

 

Sub Main()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

End Sub

 

This code will get the one view changed as I think you are requesting.  

oViews = oSheet.DrawingViews.item(whatever number view you want to change).scale = (your input)

 

When you find out what the item number is, then you can change only that one view.

 

Good Luck

Message 3 of 5
Owner2229
in reply to: Anonymous

Hi, pasting here from the msg I send you, as others might use it as well:

 

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oView As DrawingView
Dim oScale As Double

For Each oSheet As Sheet In oDrawDoc.Sheets
    For Each oView In oSheet.DrawingViews
        oScale = InputBox("Enter Desired Scale", "Scaler", "1")
        If oView.ScaleFromBase Then Continue For
        If oView.Camera.ViewOrientationType.ToString = "kIsoTopRightViewOrientation" Then
            oView.Scale = oScale
        End If
    Next
Next

 

The names of the ISO views:

kIsoBottomLeftViewOrientation

kIsoBottomRightViewOrientation

kIsoTopLeftViewOrientation

kIsoTopRightViewOrientation

 

If you want it to work for "all" these ISO views, you can replace the red line with this:

 

If Left(oView.Camera.ViewOrientationType.ToString, 4) = "kIso" Then 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 4 of 5
k14348
in reply to: Owner2229

Hi,

  i want to check what are all the scales used in Active sheet.idw? In our company we have to use limited scales. But if someone made non standard scale view i have to find that. So Can i get vba code for that?

 

2nd requirement:-

            I want to limit the scale for the views. Example  everyone should use 1:1, 1/5,1/10,1/20,1/50 we should have to use only the mentioned scale. We should not allow others to use different scales. Any idea?

 

Thank you,

karthikeyanM

Message 5 of 5
P_Korgaonkar
in reply to: k14348

Hello All,

The code is working fine, and it changes each view to the desired scale.

It keeps asking scale for each view.

 

What I am trying to do is a little different.

 

I am creating Flatt Pattern drawing for Laser cutting, and all the views must be of the same scale.

 

I need each and every view on the sheet to be same. So I prefer to set scale only once and all the views should change to that scale.

 

to avoid confusion I have copy-paste the code given by Emiller29 at the start of this thread.

 

Any help appreciated

 

Regards

Parag

 

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oSheets As Sheets
Dim oView As DrawingView
Dim oViews As DrawingViews
Dim oScale As Double

oSheets = oDrawDoc.Sheets
For Each oSheet In oSheets
   oViews = oSheet.DrawingViews
   For Each oView In oViews
oScale = InputBox("Enter Desired Scale", "Scaler", "1")
    
       If oView.ScaleFromBase = False Then
           oView.Scale = oScale
       End If
   Next
Nexto  

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report