iLogic Drawing View File Type Identification

iLogic Drawing View File Type Identification

Anonymous
Not applicable
1,308 Views
9 Replies
Message 1 of 10

iLogic Drawing View File Type Identification

Anonymous
Not applicable

Hi,

I'm trying to identify the file subtype of a selected drawing view using an iLogic rule (I want to perform further operations on the model referenced by the drawing view, but only if it references an assembly).

I know it will be some version of this code: http://inventortrenches.blogspot.ca/2013/03/determine-file-type-for-ilogic-rule.html

but my programming skills are far too rookie. Can someone help?

 

Thanks,

0 Likes
1,309 Views
9 Replies
Replies (9)
Message 2 of 10

chrisw01a
Collaborator
Collaborator

Hey, I am trying to do this and I cannot figure it out.  Can someone shed some light on this please?

It is not picking up something because it puts the same string on parts and assemblies.

 

See red text in the code below.

 

'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

 

 

0 Likes
Message 3 of 10

Anonymous
Not applicable

Hi can you explain a bit further what your workflow would be, are you hoping to run the rule then select a drawing view to query? Are there numerous model references on the one drawing?

 

I generally only have one model reference on my drawings and use this to determine its document type:

 

If ThisDoc.ModelDocument Is Nothing Then
MsgBox("There is no referenced model in document")
Exit Sub
End If

 

If ThisDoc.ModelDocument.DocumentType = kAssemblyDocumentObject Then
MsgBox("The referenced model is an assembly")
' Do something with the assembly
Else
MsgBox("The referenced model is not an assembly")
End If

0 Likes
Message 4 of 10

Anonymous
Not applicable

@chrisw01a your If statement is querying oModel, if you have more than one model referenced on your drawing, oModel will be the view that was placed first (see image attached)

 

 

0 Likes
Message 5 of 10

chrisw01a
Collaborator
Collaborator

I have multiple sheets and multiple views per sheet.  I need to iterate through the views (which the code is already doing) and determine if the model is of the part type or assembly type.

 

Thank you

Chris

0 Likes
Message 6 of 10

Anonymous
Not applicable

To query the model referenced by a certain view, you will need to declare a new variable that gets the referenced model of that view:

 

Dim oViewModelDoc As Document
Set oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

0 Likes
Message 7 of 10

chrisw01a
Collaborator
Collaborator

Rule Compile Errors in IDW Add View Label, in -A.idw

Error on Line 15 : 'Let' and 'Set' assignment statements are no longer supported.

0 Likes
Message 8 of 10

Anonymous
Not applicable

Sorry that was in VBA, this should work for you:

 

'***** START OF 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

 

Dim oViewModelDoc As Document
oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument


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 oViewModelDoc.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

0 Likes
Message 9 of 10

chrisw01a
Collaborator
Collaborator

At any rate, I have this working now.

 

Thank you very much.  And thank to the others that replied as well.

 

Have a great week!

 

Chris

0 Likes
Message 10 of 10

chrisw01a
Collaborator
Collaborator

After looking at this,  I don't know how it was functioning to begin with since "oModel" was declared globally...

0 Likes