iLogic rule to display all views which are a different scale to the first view.

matthew.johnson200
Enthusiast
Enthusiast

iLogic rule to display all views which are a different scale to the first view.

matthew.johnson200
Enthusiast
Enthusiast

Hi, i have an ilogic rule which i use and it works quite well. It looks through all the views on a drawing and checks to see if the scale is the same scale as the first view on the sheet. If there are any that are not then it will display a message saying 'Some views are not the same.' I would like to change this dialog so if it does identify any that have a different scale it will show a list of each view and which sheet it is on. I have a had a try of it my iLogic knowledge is very limited so i couldn't get it to work. I've attached the code i currently use.

 

Thanks.

 

Dim oDrawDoc As DrawingDocument 
Dim oSheet As Sheet
Dim oCurrentSheet As Sheet
Dim oSheets As Sheets
Dim oView As DrawingView
Dim oViews As DrawingViews
Dim oScale As Double
Dim oFView As String

On Error Resume Next
'get the current drawing
oDrawDoc = ThisDoc.Document
'get the active sheet
oCurrentSheet = oDrawDoc.ActiveSheet
'get the sheets collection
oSheets = oDrawDoc.Sheets
'look at each sheet
For Each oSheet In oSheets
	oFlag = True 'set flag to default value 
	oSheet.Activate 'activate the sheet
	oViews = oSheet.DrawingViews 'get the views collection
	oFView = oSheet.DrawingViews(1).Name 'adds the NAME of the first view in sheet to oFView
	oScale = ActiveSheet.View(oFView).Scale 'sets the SCALE of the first view to OScale
	'look at each view
	For Each oView In oViews
		'compare view scale to 1st view scale
		If oView.Scale <> oScale Then
			oFlag = False 'trip the flag
		End If
	Next
	'alert user if flag is tripped (indicating differing scales)
	If oFlag = False Then	
		MessageBox.Show("Some drawing views on " & _
		oSheet.Name & " are not the same scale. Please make all scales on this sheet the same.", "Check Scales")
	End If
Next

'set original sheet as active
oCurrentSheet.Activate

 

0 Likes
Reply
Accepted solutions (1)
1,163 Views
7 Replies
Replies (7)

WCrihfield
Mentor
Mentor

See if this works for you:

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oScale As Double
Dim oVList As List(Of String) 'the list of views that don't match 1st views scale on each page
For Each oSheet In oDDoc.Sheets
	oViews = oSheet.DrawingViews
	For Each oView In oSheet.DrawingViews
		oScale = oSheet.DrawingViews.Item(1).Scale
		If oView.Scale <> oScale Then
			oVList.Add("View: [" & oView.Name & "] on Sheet: [" & oSheet.Name & "]")
		End If
	Next
Next
InputListBox("The scale of these views didn't match first view on same sheet.", oVList, oVList(1), "SCALE MIS-MATCH")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

matthew.johnson200
Enthusiast
Enthusiast

Thanks for the response. 

I cant get it work , i'm getting 'Object reference not set to an instance of an object.'

 

Thanks

0 Likes

WCrihfield
Mentor
Mentor

It must not have liked how I attempted to specify the default value within the InputListBox function.

Lets try it without specifying a default value.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oScale As Double = 0
Dim oVList As List(Of String) 'the list of views that don't match 1st views scale on each page
For Each oSheet In oDDoc.Sheets
	oViews = oSheet.DrawingViews
	For Each oView In oSheet.DrawingViews
		oScale = oSheet.DrawingViews.Item(1).Scale
		If oView.Scale <> oScale Then
			oVList.Add("View: [" & oView.Name & "] on Sheet: [" & oSheet.Name & "]")
		End If
	Next
Next
InputListBox("The scale of these views didn't match first view on same sheet.", oVList)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

matthew.johnson200
Enthusiast
Enthusiast

Sorry but still can't get it to work.

0 Likes

WCrihfield
Mentor
Mentor
Accepted solution

Aha.  Sorry about that.  Sometimes I get in too much of a hurry.  I see where it's missing a word now.  I created a mock-up of your situation to test the code on this time.  I was forgetting one little important word that's easy to forget.  I had to create a NEW instance of a List.

This time it is tested and working on my end.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oScale As Double = 0
Dim oVList As New List(Of String) 'the list of views that don't match 1st views scale on each page
For Each oSheet In oDDoc.Sheets
	oViews = oSheet.DrawingViews
	For Each oView In oSheet.DrawingViews
		oScale = oSheet.DrawingViews.Item(1).Scale
		If oView.Scale <> oScale Then
			oVList.Add("View: [" & oView.Name & "] on Sheet: [" & oSheet.Name & "]")
		End If
	Next
Next
InputListBox("The scale of these views didn't match first view on same sheet.", oVList)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

matthew.johnson200
Enthusiast
Enthusiast

Works great! Thanks for your help.

0 Likes

rhasell
Advisor
Advisor

Hi

 

Thank you

 

I added one additional line to the bottom of your code:

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oScale As Double = 0
Dim oVList As New List(Of String) 'the list of views that don't match 1st views scale on each page
For Each oSheet In oDDoc.Sheets
	oViews = oSheet.DrawingViews
	For Each oView In oSheet.DrawingViews
		oScale = oSheet.DrawingViews.Item(1).Scale
		If oView.Scale <> oScale Then
			oVList.Add("View: [" & oView.Name & "] on Sheet: [" & oSheet.Name & "]")
		End If
	Next
Next
If oVList.Count=0 Then
	MessageBox.Show("All Views match the base view", "Scale Check")
	Else
InputListBox("The scale of these views didn't match first view on same sheet.", oVList)
End If

 

 

Reg
2025.2
0 Likes