Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic - Change the scale on a selected view

Anonymous

iLogic - Change the scale on a selected view

Anonymous
Not applicable

Hello All,

I am new to iLogic, although i have been tinkering around with some code i find online and attending Youtube Universtiy. I am trying to make an iLogic rule that will allow me to change the scale of a selected view. The problem I am running across is that I don't know the correct "verbiage" to call on the view when selected. Can anyone help?

0 Likes
Reply
1,007 Views
3 Replies
Replies (3)

WCrihfield
Mentor
Mentor

Here is some iLogic code that will prompt you to change the Scale of the selected DrawingView.

It uses the SelectSet, so you would have to select the view just before running the rule.

If you would rather select the view after starting the rule, you can switch the SelectSet portion of the code out and use Dim oView As DrawingView =  ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewObject,"Select a drawing view.") command, to pause and allow you to choose the view.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSelSet As SelectSet = oDDoc.SelectSet
If oSelSet.Count > 0 And _
	oSelSet.Item(1).Type = ObjectTypeEnum.kDrawingViewObject Then
	Dim oView As DrawingView = oSelSet.Item(1)
	If oView.ScaleFromBase = False Then
		'oView.Scale = InputBox("Enter a decimal number as the new Scale of this View.", "CHANGE VIEW SCALE", oView.Scale)
		oView.ScaleString = InputBox("Enter a String that represents the new Scale of this View.", "CHANGE VIEW SCALE", oView.ScaleString)
	Else
		MsgBox("The selected View's Scale is set by the Base View, and can't be changed this way.",vbOKOnly + vbExclamation," ")
	End If
Else
	MsgBox("The selected item wasn't a DrawingView. Exiting rule.",vbOKOnly + vbExclamation," ")
End If

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Anonymous
Not applicable

Thanks for the reply!

As i mentioned before, I'm a complete newbie as iLogic goes. Does 

"If you would rather select the view after starting the rule, you can switch the SelectSet portion of the code out and use Dim oView As DrawingView =  ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewObject,"Select a drawing view.") command, to pause and allow you to choose the view."

mean replacing only that line or replacing oView at every instance of oSelSet?

 

Thanks again! 

0 Likes

WCrihfield
Mentor
Mentor

Like this:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view.")
If oView IsNot Nothing Then
	If oView.ScaleFromBase = False Then
'		oView.Scale = InputBox("Enter a decimal number as the new Scale of this View.", "CHANGE VIEW SCALE", oView.Scale)
		oView.ScaleString = InputBox("Enter a String that represents the new Scale of this View.", "CHANGE VIEW SCALE", oView.ScaleString)
	Else
		MsgBox("The selected View's Scale is set by the Base View, and can't be changed this way.",vbOKOnly + vbExclamation," ")
	End If
End If

By the way...the one line that is greyed out with a comment mark (oView.Scale = ), is there to show you an alternate way to change the scale.  If you delete that little comment mark ( ' ) at the front of that line, it will cause that line to run, but you don't want both lines to run, so you'll have to leave one of those two lines commented out.

If you use the currently active line, you can type in a fraction, as you're probably used to, but if you'd rather type in a decimal, you can comment out the active line, then un-comment the other line.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes