Selected Drawing Views

Selected Drawing Views

KWarrenCA
Advocate Advocate
528 Views
2 Replies
Message 1 of 3

Selected Drawing Views

KWarrenCA
Advocate
Advocate

I have some iLogic that allows the user to select if the view is a flat pattern or drawing view and changes the view label to have certain properties pulled from the iproperties of the part. I'm looking to change it to allow to user to preselect one or more views and have it run through each view and change the label of each one. I'm looking for some code that will help with the preselected views. Below is my current working code prior to any changes.

booleanParam = InputRadioBox("Select type of view", "Flat Pattern View", "Drawing View", True, "Select View Type")

If booleanParam = True Then
	Dim oView As DrawingView
	oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
	oView.ShowLabel = True 'show label for selected view


	If oView IsNot Nothing Then
		''Get Information from view model
		oDescription = "<StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
		''Used for part number
		'oSize = "<StyleOverride Underline='True'> <Property Document='model' PropertySet='Design Tracking Properties' Property='Size' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
		oLabel = "<StyleOverride Underline='True' FontSize='0.456875' Bold='True'><Property Document='model' PropertySet='User Defined Properties' Property='Label' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='5'>SIZE</Property></StyleOverride>"
		oStringScale = "<Br/><StyleOverride Underline='False' FontSize='0.305' Bold='False'>SCALE <DrawingViewScale/></StyleOverride>"
		'add to the view label
		oView.Label.FormattedText = oLabel & oStringScale
	Else
		Return
	End If
Else If booleanParam = False Then
Dim oView As DrawingView
oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
oView.ShowLabel = True 'show label for selected view
If oView IsNot Nothing Then

	oView.ShowLabel = True
	'format the model iproperties	
	oDescription = "<StyleOverride Underline='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
	oStringScale = "<Br/><StyleOverride Underline='False' FontSize='0.305' Bold='False'>SCALE <DrawingViewScale/></StyleOverride>"
	'add to the view label
	oView.Label.FormattedText = oDescription & oStringScale
Else
	Return
End If

End If

 

 

0 Likes
Accepted solutions (1)
529 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @KWarrenCA.  Below is a sample if an iLogic rule you can use as a starting point.  It starts by getting the SelectSet of the current document.  That is where objects are that have been selected before running the rule.  Then it checks its Count property, and if zero, exits the rule.  Then it creates a variable to hold all views it finds within the collection, because right now they are all of unknown object Type.  Then it attempts to loop through the contents, checks each objects Type, and if a DrawingView, adds it to the list.  When done, it checks to see if any views were added to the list, and if none, it exits the rule.  then you are ready to loop through the views in the list, and do whatever you want with them.  Just fill in your code for doing stuff with the views within that last loop.

Dim oSelectSet As SelectSet = ThisDoc.Document.SelectSet
If oSelectSet.Count = 0 Then Exit Sub 'nothing was pre-selected
Dim oPreSelectedViews As New List(Of DrawingView)
For Each oObj In oSelectSet
	If TypeOf oObj Is DrawingView Then
		Dim oSelView As DrawingView = oObj
		oPreSelectedViews.Add(oSelView)
	End If
Next
If oPreSelectedViews.Count = 0 Then Exit Sub 'none of pre-selected was view
For Each oView As DrawingView In oPreSelectedViews
	'do what you need to do to each view here
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

KWarrenCA
Advocate
Advocate

@WCrihfield  Thank you that worked perfectly!

0 Likes