iLogic Changing View Scale

iLogic Changing View Scale

Anonymous
Not applicable
2,196 Views
4 Replies
Message 1 of 5

iLogic Changing View Scale

Anonymous
Not applicable

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
0 Likes
Accepted solutions (1)
2,197 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

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

0 Likes
Message 3 of 5

Owner2229
Advisor
Advisor
Accepted solution

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
0 Likes
Message 4 of 5

k14348
Advocate
Advocate

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

0 Likes
Message 5 of 5

P_Korgaonkar
Advocate
Advocate

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  

 

0 Likes