Inventor General Discussion

Inventor General Discussion

Reply
Contributor
ben_neb43
Posts: 23
Registered: ‎08-14-2013
Message 1 of 6 (400 Views)
Accepted Solution

iLogic - Get view type

400 Views, 5 Replies
12-17-2013 01:17 PM

Could find this anywhere, Is there a way to get the "view type" of a view using iLogic? for example;

 

-detail view

-section view

-exploded view

 

Or any way to differenciate between the types of views?

 

I'm trying to write a rule that renames all detail and section views in a drawing in Alphabetical order. A,B,C,D..

 

Cheers for any help,

Ben

Do you know how to access the view object?  Because if you do, getting the view type is as simple as DrawingView.ViewType.  This will return a DrawingViewTypeEnum depending on which type it is.  The list of enums are as follows (from the 2014 API help documentation):

 

Drawing View Type Enums.PNG

 

If you don't know how to access the view object, post back with an example of your code where you need to find the view type.

 

Cameron Whetten
Inventor 2014

*Expert Elite*
cwhetten
Posts: 1,090
Registered: ‎09-03-2008
Message 2 of 6 (386 Views)

Re: iLogic - Get view type

12-17-2013 02:28 PM in reply to: ben_neb43

Do you know how to access the view object?  Because if you do, getting the view type is as simple as DrawingView.ViewType.  This will return a DrawingViewTypeEnum depending on which type it is.  The list of enums are as follows (from the 2014 API help documentation):

 

Drawing View Type Enums.PNG

 

If you don't know how to access the view object, post back with an example of your code where you need to find the view type.

 

Cameron Whetten
Inventor 2014

Distinguished Mentor
pcrawley
Posts: 703
Registered: ‎05-23-2002
Message 3 of 6 (375 Views)

Re: iLogic - Get view type

12-17-2013 03:07 PM in reply to: cwhetten
Contributor
ben_neb43
Posts: 23
Registered: ‎08-14-2013
Message 4 of 6 (360 Views)

Re: iLogic - Get view type

12-17-2013 04:55 PM in reply to: cwhetten

Thanks for the replies,

 

@Cameron, thanks I do know how to access the view object. Would you be able to provide a link to the 2014 API help documentation though?

 

Cheers,

Ben

Distinguished Mentor
pcrawley
Posts: 703
Registered: ‎05-23-2002
Message 5 of 6 (354 Views)

Re: iLogic - Get view type

12-17-2013 05:07 PM in reply to: ben_neb43

18-12-2013 2-05-47 p-m-.jpg

Peter
Contributor
ben_neb43
Posts: 23
Registered: ‎08-14-2013
Message 6 of 6 (345 Views)

Re: iLogic - Get view type

12-17-2013 05:42 PM in reply to: pcrawley

Thanks Peter!

 

by the way for anyone reading this, here's my working code below (scavenged from other forum posts too),

 

It reformats all view labels in a drawing and sequentially renames the detail and section views, in alphabetical order!!!!

 

 

Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document
oModelDoc = ThisDoc.ModelDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

ViewLetter = New String(){"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","X","W","Y","Z"}
Dim ViewCount = 0

oSheets = oDoc.Sheets

Dim view_asso_draft = 10506
Dim view_auxillary = 10499
Dim view_custom = 10498
Dim view_default = 10497
Dim view_detail = 10502
Dim view_draft = 10505
Dim view_OLE = 10500
Dim view_overlay = 10507
Dim view_projected = 10504
Dim view_section = 10503
Dim view_standard = 10501

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
' Set a reference to the mass properties object.
'Dim oMassProps As MassProperties = oModelDoc.ComponentDefinition.MassProperties

' Set the accuracy to medium.
'oMassProps.Accuracy = MassPropertiesAccuracyEnum.k_Low
'Dim M As Double = oMassProps.Mass

'Set label as visible
oView.ShowLabel = True

'Create the label strings
oView_line1_standard = "<Br/><StyleOverride Underline='True'><DrawingViewName/> VIEW</StyleOverride>"
oView_line1_detail = "<Br/><StyleOverride Underline='True'>DETAIL <DrawingViewName/></StyleOverride>"
oView_line1_section = "<Br/><StyleOverride Underline='True'>SECTION: <DrawingViewName/>-<DrawingViewName/></StyleOverride>"
oView_line2 = "<Br/><StyleOverride Underline='True'>DESC: <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
'oStringMass = "<Br/><StyleOverride Underline='True'>EST. UNIT MASS: "& FormatNumber(M, 0)&" kg</StyleOverride>"
oView_line3 = "<Br/><StyleOverride Underline='True'>SCALE <DrawingViewScale/></StyleOverride>"

'check view types
If oView.ViewType = view_detail Then
'if detail view display this label
oView.Label.FormattedText = oView_line1_detail & oView_line3
'rename as the next character in the ViewCount array
oView.Name = ViewLetter(ViewCount)
ViewCount = ViewCount + 1

Else If oView.ViewType = view_section Then
'if section view display this label
oView.Label.FormattedText = oView_line1_section & oView_line3
'rename as the next character in the ViewCount array
oView.Name = ViewLetter(ViewCount)
ViewCount = ViewCount + 1

Else
'else display this label as default
oView.Label.FormattedText = oView_line1_standard & oView_line2 & oView_line3
End If
Next
Next

Thanks for your help guys,

Ben

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.