iLogic Drawing View File Type Identification

iLogic Drawing View File Type Identification

chrisw01a
Collaborator Collaborator
1,735 Views
4 Replies
Message 1 of 5

iLogic Drawing View File Type Identification

chrisw01a
Collaborator
Collaborator

Hey guys.

This should be an easy one for you in the know...

 

Simply trying to determine if a drawing view is an assembly or part.

 

This code is skipping something because it always uses the first solution in the IF statement.

 

See red code...

 

'iterate through a IDW and add "Part Number, Total Part Qty" to the base view labels

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

For Each oSheet In oSheets
	oViews = oSheet.DrawingViews
	For Each oView In oViews
		'oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType _
		'oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType
		If oView.ViewType = DrawingViewTypeEnum.kStandardDrawingViewType Then
		
		'if viel label is hidden, unhide
		oView.ShowLabel = True
		
			Try
			'get the property ID for these custom iProperties from the model referenced by the view
			o_iPropID_1 = oModel.PropertySets.Item("User Defined Properties").Item("TotalPartQty").PropId
			o_iPropID_2 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_2").PropId
			Catch
			'here you could add a message that one or more of the custom iProperties were not found
			End Try
			Try
			'format the custom iproperty string and add the property ID
			oPartQty = "<Property Document='model' PropertySet='User Defined Properties' " _
			& "Property='TotalPartQty' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
			& o_iPropID_1 & "'>TotalPartQty</Property>"
			
			''format the custom iproperty string and add the property ID
			'oString2 = "<Property Document='model' PropertySet='User Defined Properties' " _
			'& "Property='My_iProp_2' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
			'& o_iPropID_2 & "'>My_iProp_2</Property>"
			
			'format the built in iproperty string and add the property ID
			oPartNumber = "<StyleOverride Bold='false' Underline='false'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
			'oStockNumber = "<Br/><StyleOverride Bold='false' Underline='false'><Property Document='model' PropertySet='Design Tracking Properties' Property='Stock Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>STOCK NUMBER</Property></StyleOverride>"
			'oStringScale = "<StyleOverride FontSize='0.2'> FLAT VIEW (<DrawingViewScale/>)</StyleOverride>"
			'oPartNumber = "<Br/><StyleOverride Underline='False' FontSize='0.2'>PART ID:    <Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property></StyleOverride>"
			'oStringProfile = "<Br/><StyleOverride FontSize='0.2'>PROFILE:   <Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
			oStringMaterial = "<StyleOverride Underline='False'><Property Document='model' PropertySet='Design Tracking Properties' Property='Material' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='20'>PART NUMBER</Property></StyleOverride>"
			'oStringAuth = "<Br/><StyleOverride Underline='False' FontSize='0.2'>QTY:        <Property Document='model' PropertySet='Design Tracking Properties' Property='Authority' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>AUTHORITY</Property></StyleOverride>"
			
			
				'add the custom iproperties to the view label
				'oView.Label.FormattedText = "<DrawingViewName/><Br/>" & oString1 & oString2
				
				'Here Is a list Of all Of the the DocumentType enumerators available In the API:
				'kUnknownDocumentObject 
				'kPartDocumentObject 
				'kAssemblyDocumentObject 
				'kDrawingDocumentObject 
				'kPresentationDocumentObject 
				'kDesignElementDocumentObject 
				'kForeignModelDocumentObject 
				'kSATFileDocumentObject  
				'kNoDocument
				
				'DETERMINE MODEL TYPE
				'If oModel.DocumentType = kPartDocumentObject  Then
				oView.Label.FormattedText = oPartNumber & "<Br/>" & oStringMaterial & "<Br/>" & oPartQty & " RQD " 
				'Else
				'oView.Label.FormattedText = oPartNumber & "<Br/>" & oPartQty & " RQD "
				'End If			
			
			Catch
			'do nothing if error
			End Try
		End If
	Next
Next

Accepted solutions (2)
1,736 Views
4 Replies
Replies (4)
Message 2 of 5

salariua
Mentor
Mentor
Accepted solution

I think you need to get type of model from each view rather than setting it globally at the beginning of the code. On some drawings, you could have both assemblies and parts.

 

If oModel.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject  Then

 

 

 

 

 

Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
Message 3 of 5

chrisw01a
Collaborator
Collaborator
I briefly considered that but the code has been working as it is for putting
the view labels on.

I will look into this. Thank you.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

Use this instead of oModel

 

Dim oViewModelDoc As Document
oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

 

'DETERMINE MODEL TYPE
If oViewModelDoc.DocumentType = kPartDocumentObject Then
oView.Label.FormattedText = oPartNumber & "<Br/>" & oStringMaterial & "<Br/>" & oPartQty & " RQD " 
Else
oView.Label.FormattedText = oPartNumber & "<Br/>" & oPartQty & " RQD "
End If 

Message 5 of 5

chrisw01a
Collaborator
Collaborator

Thank you for your help.

Chris

0 Likes