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 Drawing Views Scale

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
devonjohnson
8206 Views, 16 Replies

iLogic Drawing Views Scale

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

Thanks,
Devon Johnson

Inventor 2020
16 REPLIES 16
Message 2 of 17

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

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 17

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

Thanks,
Devon Johnson

Inventor 2020
Message 4 of 17

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


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 17
devonjohnson
in reply to: devonjohnson

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.

Thanks,
Devon Johnson

Inventor 2020
Message 6 of 17
mrattray
in reply to: devonjohnson

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.

Mike (not Matt) Rattray

Message 7 of 17
devonjohnson
in reply to: devonjohnson

Thanks so much Mike, thats exactly what I need!!

 

Appreciate you spending the time to help out 🙂

 

Devon

Thanks,
Devon Johnson

Inventor 2020
Message 8 of 17
devonjohnson
in reply to: devonjohnson

Hi there again,

 

I actually just tweaked the code so it applied to only the active sheet - works a treat.  Thanks again!

 

Devon

Thanks,
Devon Johnson

Inventor 2020
Message 9 of 17
Anonymous
in reply to: devonjohnson

Hi. When it run this code as a rual on a drawing I get an error 

 

Public Memeber 'DrawingViews' on Type "Sheets' not found. 

Message 10 of 17
Anonymous
in reply to: Anonymous

Never mind. I typed Sheet not Sheets. 

Message 11 of 17
Anonymous
in reply to: mrattray

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

Message 12 of 17
MechMachineMan
in reply to: Anonymous

It is missing

oSheet.Activate right after the line that has "For each oSheet in Sheets"


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 13 of 17
Anonymous
in reply to: MechMachineMan

Thanks Justin,  

 

That worked perfect.

 

CADoor 

Message 14 of 17

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! 

Message 15 of 17

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

 

Thanks,
Devon Johnson

Inventor 2020
Message 16 of 17

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

 

Thanks,
Devon Johnson

Inventor 2020
Message 17 of 17

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:

 

http://forums.autodesk.com/t5/inventor-general-discussion/overriding-auto-scale-in-title-block/m-p/6...

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Tags (1)

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

Post to forums  

Autodesk Design & Make Report