Ilogic - View Label with Custom Iproperties ignoring projected view

Ilogic - View Label with Custom Iproperties ignoring projected view

iqea.rogelio.auto
Explorer Explorer
431 Views
3 Replies
Message 1 of 4

Ilogic - View Label with Custom Iproperties ignoring projected view

iqea.rogelio.auto
Explorer
Explorer

Hello. Pleas I need some help, with this, i really try from many ways, but my knowledge of coding tis pretty basic

I am working with this little code that get the "Custom Iproperties" from the assemblies & parts into the drawing view labels, and it works fine, actually more than I want.

I want to run the rule only for the "Base View" because I don't wanna see all the information of the part/assemblies in the projected view again, I want to see only the custom IPropeties that I call "Item#" & "name view (ex. Side. Top etc.)  in the projected views.

 

I run two rules now, 

#1 for the View Names

#2 for the Label information (Custom Iproperties)

 

Rule#1

 

'active sheet
Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet


Dim tmpView As DrawingView

For Each tmpView In tmpSheet.DrawingViews

    Dim myDrawingViewName As String = ""
    
	If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then
    
        'Which text for which orientation
        Select Case tmpView.Camera.ViewOrientationType
            Case ViewOrientationTypeEnum.kBackViewOrientation
                myDrawingViewName = "Back View"
            Case ViewOrientationTypeEnum.kBottomViewOrientation
                myDrawingViewName = "Bottom View"
            Case ViewOrientationTypeEnum.kFrontViewOrientation
                myDrawingViewName = "Front View"
            Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation
                myDrawingViewName = "Isometric View"
            Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation
                myDrawingViewName = "Isometric View"
            Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
                myDrawingViewName = "Isometric View"
            Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation
                myDrawingViewName = "Isometric View"
            Case ViewOrientationTypeEnum.kLeftViewOrientation
                myDrawingViewName = "Left View"
            Case ViewOrientationTypeEnum.kRightViewOrientation
                myDrawingViewName = "Right View"
            Case ViewOrientationTypeEnum.kTopViewOrientation
                myDrawingViewName = "Top View"
            Case Else
                myDrawingViewName = ""
            End Select
        
        'Change if view orientation was found
        If Not myDrawingViewName = "" Then
            'change drawing view name
            tmpView.Name = myDrawingViewName
        End If
		
		If tmpView.isflatpatternview =True Then
        tmpView.Name = "FLAT PATTERN"
		 End If
    
    End If

    myDrawingViewName = ""

Next

Rule #2

 

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

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

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
oView.ShowLabel = True


		Try
		'get the property ID for these custom iProperties from the model referenced by the view
		o_iPropID_0 = oModel.PropertySets.Item("User Defined Properties").Item("Item#").PropId
		o_iPropID_1 = oModel.PropertySets.Item("User Defined Properties").Item("Title_").PropId
		o_iPropID_2 = oModel.PropertySets.Item("User Defined Properties").Item("Description_").PropId
		o_iPropID_3 = oModel.PropertySets.Item("User Defined Properties").Item("Finish").PropId
		o_iPropID_4 = oModel.PropertySets.Item("User Defined Properties").Item("Qty#").PropId
		
		    
		
		Catch
		'here you could add a message that one or more of the custom iProperties were not found
		End Try
		
		'set prefix, if needed
 Dim sPrefix As String
 sPrefix0 = "ITEM: "
 sPrefix1 = "TITLE: "
 sPrefix2 = "DESCRIPTION: "
 sPrefix3 = "FINISH: "
 sPrefix4 = "TOTAL Req.: "

 
		
		Try		
		'format the custom iproperty string and add the property ID
		oString0 = sPrefix0 & "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='Item#' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_0 & "'>item#</Property><Br/>" 
		
		'format the custom iproperty string and add the property ID
		oString1 = sPrefix1 & "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='Title_' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_1 & "'>Title_</Property><Br/>"
		
		'format the custom iproperty string and add the property ID
		oString2 = sPrefix2 &  "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='Description_' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_2 & "'>Description_</Property><Br/>"
		
		'format the custom iproperty string and add the property ID
		oString3 = sPrefix3 &  "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='Finish' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_3 & "'>Finish</Property><Br/>"
		
		'format the custom iproperty string and add the property ID
		oString4 = sPrefix4 &  "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='Qty#' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_4  & "'>Qty#</Property><Br/>"

		'add the custom iproperties to the view label
		oView.Label.FormattedText = "<DrawingViewName/><Br/>" & oString0 & oString1 & oString2 & oString3 & oString4
		
		
		Catch
		'do nothing if error
		End Try
		If Not oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft Then
        oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
    End If
	Next
Next

And I get this.

 

attached file

Im1.png

 

0 Likes
432 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @iqea.rogelio.auto 

 

Here is an example that shows how to work with the view type.

 

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

Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
	For Each oView In oViews
       
	 	If oView.ViewType = DrawingViewTypeEnum.kStandardDrawingViewType Then
			oView.ShowLabel = True
		Else
			oView.ShowLabel = False
	 	End If
	Next
Next

 

 

EESignature

0 Likes
Message 3 of 4

iqea.rogelio.auto
Explorer
Explorer

Thank you for the answer. I added that part of the code, but it hide the projected view , i need to keep the "Item#" & the name of the view

0 Likes
Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @iqea.rogelio.auto 


That was just an example of how to access the ViewTypes, you'll need adjust it as needed to do what you're code intent is. here is the full list of the drawingviewype enums.

 

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

 

 

DrawingViewTypeEnum Enumerator

Description

Drawing View Type.

Methods

Name Value Description
kAssociativeDraftDrawingViewType 10506 View is an associative draft one.
kAuxiliaryDrawingViewType 10499 View is an auxiliary one.
kCustomDrawingViewType 10498 View with customized camera setting.
kDefaultDrawingViewType 10497 Specifies the default View. The more strongly typed value is returned in a query.
kDetailDrawingViewType 10502 View is a detail of a portion of the document contents.
kDraftDrawingViewType 10505 View is a draft one.
kOLEAttachmentDrawingViewType 10500 View is an OLE attachment.
kOverlayDrawingViewType 10507 View is an overlay one.
kProjectedDrawingViewType 10504 View is a projected one.
kSectionDrawingViewType 10503 View is a section.
kStandardDrawingViewType 10501 View with the camera set to one of the standard orthogonal views (Top, Iso, etc.).

 

EESignature

0 Likes