Hi there,
I'm trying to put together some iLogic code to either check all the drawing views within a drawing sheet are all the same scale, or make the views all the same scale. These drawing sheets consist of a number of individual parts (they aren't projected views from a single part).
This is for welded assemblies. We are required to generate a profile drawing sheet outlining each part that makes up the assembly. We send these out as dwg files for laser cutting so its important that the views are all the same scale.
Any help would be much appreciated, it's a tedious checking process at the moment!
Thanks
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
You may get scale for any drawing view in the drawing document.
Here is the sample iLogic rule that show scale of al drawing views in the drawing document.
'active drawing document Dim oDrawDoc As DrawingDocument = ThisDrawing.Document 'get scale of all views in this drawing document For Each oSheet As Sheet In oDrawDoc.Sheets For Each oView As DrawingView In oSheet.DrawingViews MsgBox("Sheet: " & oSheet.Name & vbNewLine & _ "View: " & oView.Name & vbNewLine & _ "Scale: " & oView.Scale) Next Next
Thanks for that, can this be amended to actually set the scale of all the views on a drawing sheet though? Or link all the views to the base view scale?
Thanks for your help
Yes, DrawingView.Scale property gets and sets the model to paper space scale of the view.
But setting this property is sensible only if the DrawingView.ScaleFromBase property returns False.
See the section "DrawingView" in the Inventor API help.
cheers
Thanks........ I want to set all the views in the drawing sheet to be scaled the same as the base view scale. I have code which displays a messagebox asking what scale the views need to be, but you have to enter a value for every view. I just need all the views to be the same scale.
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 oScale = InputBox("Enter Desired Scale", "Scaler", "1") oSheets = oDrawDoc.Sheets For Each oSheet In oSheets oViews = oSheet.DrawingViews For Each oView In oViews If oView.ScaleFromBase = False Then oView.Scale = oScale End If Next Next
Try this. You can change the behaviour of the input box by changing its location in the code. As it is, it will ask you once and set every view to that scale. If you put it under "For Each oSheet" then it will allow you to specify a different scale for each sheet, or if you put it under "For Each oView" then you'll have to specify a scale for every view on every sheet.
Thanks so much Mike, thats exactly what I need!!
Appreciate you spending the time to help out 🙂
Devon
Hi there again,
I actually just tweaked the code so it applied to only the active sheet - works a treat. Thanks again!
Devon
Hi. When it run this code as a rual on a drawing I get an error
Public Memeber 'DrawingViews' on Type "Sheets' not found.
Hello Mike,
This is a great code! I'm trying to modify it to work when the sheet is active, so i can see the change. I have a total of 6 sheet. Can you tell me what part of the code is missing to do that?
Thanks
CADoor
It is missing
oSheet.Activate right after the line that has "For each oSheet in Sheets"
i saw this post, and cannot get it to change scales on the active sheet with the code from this post. is it supposed to be...
For Each oSheet In oSheets
oSheet.Activate oViews = oSheet.DrawingViews
any help is greatly appreciated. thanks!
This the code that works for me, it works on any sheet I have active.
Dim oDrawDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet Dim oView As DrawingView Dim oViews As DrawingViews Dim oScale As String oScale = InputBox("Enter Desired Scale", "Scaler", "1:1") oSheet = oDrawDoc.ActiveSheet oViews = oSheet.DrawingViews For Each oView In oViews If oView.ScaleFromBase = False Then oView.ScaleString = oScale End If Next
This the code that works for me, it works on any sheet I have active.
Dim oDrawDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet Dim oView As DrawingView Dim oViews As DrawingViews Dim oScale As String oScale = InputBox("Enter Desired Scale", "Scaler", "1:1") oSheet = oDrawDoc.ActiveSheet oViews = oSheet.DrawingViews For Each oView In oViews If oView.ScaleFromBase = False Then oView.ScaleString = oScale End If Next
In case someone wants to go the other direction and keep scales that vary, there is a bit of iLogic at this link to check each view scale on the sheet and update the title block to read Varies if they are not all the same scale:
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Can't find what you're looking for? Ask the community or share your knowledge.