Material of the model property in drawing view label.

Material of the model property in drawing view label.

aurel_e
Collaborator Collaborator
1,576 Views
8 Replies
Message 1 of 9

Material of the model property in drawing view label.

aurel_e
Collaborator
Collaborator

Hi all,

I use the code below to add Part number and quantity per each view in the drawing.

I would like to show the part material as well but not being able to find anything similar.

' Set a reference to the drawing document.' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oViews = oActiveSheet.DrawingViews
For Each oView In oViews
	If oView.ViewType <> 10504 And oView.ViewType <> 10502 And oView.ViewType <> 10503 And oView.IsFlatPatternView = False Then ' Not kProjectedDrawingViewType
		'Get the full filename Of the view model
		Dim oModelFileName As String
		oModelFileName = oView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item(2).Value



		
		'format the text first line
		oStringItem = "<StyleOverride Underline='True' FontSize='0.35'> ITEM " & oItemValue & " </StyleOverride>"
		'format the text second line
		oStringScale = "<Br/><StyleOverride FontSize='0.3'>(Scale <DrawingViewScale/>)</StyleOverride>"
		'add to the view label
		oQty = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='FALSE'>" _
		& "Quantity: " & "<Property Document='model' PropertySet='User Defined Properties' Property='Qty' "  & _
		"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' >Qty</Property></StyleOverride>" 
		

		oView.Label.FormattedText = oModelFileName & "<Br/>" _
		& oQty
		CentText = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X - oView.Width/5, oView.Center.Y - oView.Height / 1.8 )
		oView.Label.Position= CentText
		oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
		oView.ShowLabel = True

	End If
Next
0 Likes
Accepted solutions (1)
1,577 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Try it with this edit:

' Set a reference to the drawing document.' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oViews As DrawingViews = oDrawDoc.ActiveSheet.DrawingViews
Dim oView As DrawingView
Dim oPropSet As PropertySet ' "Design Tracking Properties" set
Dim oModelFileName As String
Dim oMaterial As String

For Each oView In oViews
	If oView.ViewType <> 10504 And oView.ViewType <> 10502 And oView.ViewType <> 10503 And oView.IsFlatPatternView = False Then ' Not kProjectedDrawingViewType
		oPropSet = oView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets(3)
		'Get the full filename Of the view model
		oModelFileName = oPropSet(2).Value

		'format the text first line
		oStringItem = "<StyleOverride Underline='True' FontSize='0.35'> ITEM " & oItemValue & " </StyleOverride>"
		'format the text second line
		oStringScale = "<Br/><StyleOverride FontSize='0.3'>(Scale <DrawingViewScale/>)</StyleOverride>"
		'add to the view label
		oQty = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='FALSE'>" _
		& "Quantity: " & "<Property Document='model' PropertySet='User Defined Properties' Property='Qty' "  & _
		"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' >Qty</Property></StyleOverride>" 
		oMaterial = oPropSet(10).Value
		
		oView.Label.FormattedText = oModelFileName & "<Br/>" & oQty & "<Br/>" & oMaterial
		CentText = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X - oView.Width/5, oView.Center.Y - oView.Height / 1.8 )
		oView.Label.Position= CentText
		oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
		oView.ShowLabel = True

	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 9

aurel_e
Collaborator
Collaborator

 

Wow! It's what I was looking for.

I tried for 2 hours to find something in web but no success.

Where did you find that 

oMaterial = oPropSet(10).Value

I suppose this is an experience matter, but I was looking to identify the model properties in the left side of the Ilogic editor interface:  

 

2020-06-04 15_54_54-Edit Rule_ Rule15.png

0 Likes
Message 4 of 9

WCrihfield
Mentor
Mentor

You can find the local iProperty for the local Material under the Snippets / System tab / iProperties / Material, but that isn't what I used, because that wouldn't work for your situation.  I have a rule that writes all iProperties to a TXT file, which I keep a copy of in MyDocuments, for quick reference.  It lists every PropertySet (in order, and by name), and every Property (in order, and by name) within each PropertySet.  This makes it quick and simple to know exactly what PropertySet item number or name, and exactly what Property item number or name to use in my codes.  Like a cheat sheet or quick reference.  There is also a property further down the same set for "Material Identifier" (item # 52).

Of course there is also the iProperties.Value(oComp or oDoc,"PropertySet Name","Property Name") = , or iProperties.Expression(.... route too.  Whichever you prefer.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 9

dlongley
Enthusiast
Enthusiast

Hi there,

 

Any chance you could post either the TXT file or that rule that lists all he properties?

 

Many thanks for your help.

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

Sure.  Here is one of the simpler iLogic rules for writing out a list of all the iProperty names & ID's to a new text file.

As you can see, line two is pointing to the Windows Temp folder, which is where the new text file will be created, if not changed.  Just so you know where the file will be located, even though the last line launches that text file for you to view.

Dim oDoc As Document = ThisDoc.Document
Dim oTxtFile As String = "C:\Temp\List Of All iProperties.txt"
If System.IO.File.Exists(oTxtFile) Then
	oAns = MsgBox("The text file already exists." & vbCrLf & _
	"Do you want to overwrite it?", vbYesNo + vbQuestion, "FILE EXISTS")
	If oAns = vbNo Then Exit Sub
End If
Dim oWriter As System.IO.StreamWriter
oWriter = System.IO.File.CreateText(oTxtFile)
oWriter.WriteLine("List Of All iProperties:")
oWriter.WriteLine("")
For i As Integer = 1 To oDoc.PropertySets.Count
	Dim oSet As PropertySet = oDoc.PropertySets.Item(i)
	oWriter.WriteLine("")
	oWriter.WriteLine(i & ")  " & oSet.Name & " (Internal Name = " & oSet.InternalName & ")")
	For j As Integer = 1 To oSet.Count
		Dim oProp As Inventor.Property = oSet.Item(j)
		oWriter.WriteLine(vbTab & j & ")  " & oProp.Name & " (PropID = " & oProp.PropId & ")")
	Next
Next
oWriter.Close()
ThisDoc.Launch(oTxtFile)

There is a lot more info that could be written out to the text file about these items, but I wanted to keep this version simple.  I also have some other similar rules that write more data out, and some that write data out to Excel, instead of a text file.  Similar steps can be used to list out data about Parameters and other similar complex lists/collections of objects that you may reference often.

 

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 9

dlongley
Enthusiast
Enthusiast

That's excellent, answers some questions about how to get at some of the info.  Many thanks for your help.

0 Likes
Message 8 of 9

max.baumann07
Enthusiast
Enthusiast

Hi,
Can you help me what I need to do to show the materials per part?

I have an assembly with different parts, each part has a different material. In the assembly I create different views which I then transfer to the drawing. In these views I would like to have the material of the parts in addition to the model name and the scale.

Unfortunately I can't find a solution for the materials.

0 Likes
Message 9 of 9

maxim.teleguz
Advocate
Advocate

here is a simple solution for adding anything you want to your labels that is linked:


Dim oApp As Application = ThisApplication
Dim dDoc As DrawingDocument = TryCast(oApp.ActiveDocument, DrawingDocument)

If IsNothing(dDoc) Then
    Logger.Debug("Not A Drawing Document")
    Exit Sub
End If

' Get User to select a view
Dim PickView As DrawingView = oApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View")
If IsNothing(PickView) Then
    Exit Sub ' If nothing gets selected then we're done
End If

' Set a reference to the drawing document.' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oViews As DrawingViews = oDrawDoc.ActiveSheet.DrawingViews
Dim oView As DrawingView
Dim oPropSet As PropertySet ' "Design Tracking Properties" set
Dim oModelFileName As String
Dim oMaterial As String

oPropSet = PickView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets(3)
oModelFileName = oPropSet(2).Value
PickView.Label.FormattedText = "<Property Document='model' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>Part Number</Property>"
PickView.ShowLabel = True

'List Of All iProperties:


'1)  Inventor Summary Information (Internal Name = {F29F85E0-4FF9-1068-AB91-08002B27B3D9})
'	1)  Title (PropID = 2)
'	2)  Subject (PropID = 3)
'	3)  Author (PropID = 4)
'	4)  Keywords (PropID = 5)
'	5)  Comments (PropID = 6)
'	6)  Last Saved By (PropID = 8)
'	7)  Revision Number (PropID = 9)
'	8)  Thumbnail (PropID = 17)

'2)  Inventor Document Summary Information (Internal Name = {D5CDD502-2E9C-101B-9397-08002B2CF9AE})
'	1)  Category (PropID = 2)
'	2)  Manager (PropID = 14)
'	3)  Company (PropID = 15)

'3)  Design Tracking Properties (Internal Name = {32853F0F-3444-11D1-9E93-0060B03C1CA6})
'	1)  Creation Time (PropID = 4)
'	2)  Part Number (PropID = 5)
'	3)  Project (PropID = 7)
'	4)  Cost Center (PropID = 9)
'	5)  Checked By (PropID = 10)
'	6)  Date Checked (PropID = 11)
'	7)  Engr Approved By (PropID = 12)
'	8)  Engr Date Approved (PropID = 13)
'	9)  User Status (PropID = 17)
'	10)  Material (PropID = 20)
'	11)  Part Property Revision Id (PropID = 21)
'	12)  Catalog Web Link (PropID = 23)
'	13)  Part Icon (PropID = 28)
'	14)  Description (PropID = 29)
'	15)  Vendor (PropID = 30)
'	16)  Document SubType (PropID = 31)
'	17)  Document SubType Name (PropID = 32)
'	18)  Proxy Refresh Date (PropID = 33)
'	19)  Mfg Approved By (PropID = 34)
'	20)  Mfg Date Approved (PropID = 35)
'	21)  Cost (PropID = 36)
'	22)  Standard (PropID = 37)
'	23)  Design Status (PropID = 40)
'	24)  Designer (PropID = 41)
'	25)  Engineer (PropID = 42)
'	26)  Authority (PropID = 43)
'	27)  Parameterized Template (PropID = 44)
'	28)  Template Row (PropID = 45)
'	29)  External Property Revision Id (PropID = 46)
'	30)  Standard Revision (PropID = 47)
'	31)  Manufacturer (PropID = 48)
'	32)  Standards Organization (PropID = 49)
'	33)  Language (PropID = 50)
'	34)  Defer Updates (PropID = 51)
'	35)  Size Designation (PropID = 52)
'	36)  Categories (PropID = 56)
'	37)  Stock Number (PropID = 55)
'	38)  Weld Material (PropID = 57)
'	39)  Mass (PropID = 58)
'	40)  SurfaceArea (PropID = 59)
'	41)  Volume (PropID = 60)
'	42)  Density (PropID = 61)
'	43)  Valid MassProps (PropID = 62)
'	44)  Flat Pattern Width (PropID = 63)
'	45)  Flat Pattern Length (PropID = 64)
'	46)  Flat Pattern Area (PropID = 65)
'	47)  Sheet Metal Rule (PropID = 66)
'	48)  Last Updated With (PropID = 67)
'	49)  Sheet Metal Width (PropID = 68)
'	50)  Sheet Metal Length (PropID = 69)
'	51)  Sheet Metal Area (PropID = 70)
'	52)  Material Identifier (PropID = 71)
'	53)  Appearance (PropID = 72)
'	54)  Flat Pattern Defer Update (PropID = 73)

'4)  Inventor User Defined Properties (Internal Name = {D5CDD505-2E9C-101B-9397-08002B2CF9AE})
'	1)  Scale (PropID = 5)
'	2)  2 Place Decimal (PropID = 7)
'	3)  3 Place Decimal (PropID = 8)
'	4)  Checker Date (PropID = 10)
'	5)  Creation Date (PropID = 11)
'	6)  Degrees (PropID = 12)
'	7)  Designer Date (PropID = 14)
'	8)  Next Assy 1 (PropID = 19)
'	9)  Next Assy 2 (PropID = 20)
'	10)  Next Assy 3 (PropID = 21)
'	11)  Next Assy 4 (PropID = 22)
'	12)  Next Assy 5 (PropID = 23)
'	13)  Used On 1 (PropID = 25)
'	14)  Used On 2 (PropID = 26)
'	15)  Used On 3 (PropID = 27)
'	16)  Used On 4 (PropID = 28)
'	17)  Used On 5 (PropID = 29)
'	18)  Elec. Eng. Date (PropID = 31)
'	19)  Flat Pattern (PropID = 33)
'	20)  Mech. Eng. Date (PropID = 34)
'	21)  Checker (PropID = 35)
'	22)  Elec. Engineer (PropID = 36)
'	23)  Mech. Engineer (PropID = 37)
'	24)  Designer (PropID = 38)
'	25)  By (PropID = 40)
'	26)  Date (PropID = 41)
'	27)  Doc Type (PropID = 42)

'5)  Piping Style (Internal Name = {344C6667-62E9-41A8-87AD-1C862B5638BF})
'	1)  Name (PropID = 3)
'	2)  ActiveState (PropID = 4)
'	3)  PipeType (PropID = 5)
'	4)  RoutePreview (PropID = 6)
'	5)  Material (PropID = 7)
'	6)  Standard (PropID = 8)
'	7)  FittingMaterial (PropID = 9)
'	8)  FittingStandard (PropID = 10)
'	9)  RouteDirection90 (PropID = 11)
'	10)  RouteDirection45 (PropID = 12)
'	11)  DiameterType (PropID = 13)
'	12)  Diameter (PropID = 14)
'	13)  Schedule (PropID = 15)
'	14)  OD (PropID = 16)
'	15)  ID (PropID = 17)
'	16)  Ending (PropID = 18)
'	17)  IntermediateSegmentsMin (PropID = 19)
'	18)  IntermediateSegmentsMax (PropID = 20)
'	19)  IntermediateSegmentsInc (PropID = 21)
'	20)  TerminationSegmentsMin (PropID = 22)
'	21)  TerminationSegmentsMax (PropID = 23)
'	22)  TerminationSegmentsInc (PropID = 24)
'	23)  RoundUpValue (PropID = 25)
'	24)  DefaultBendRadius (PropID = 26)
'	25)  BendRadius (PropID = 27)
'	26)  SolidRoutePreviewColor (PropID = 28)
'	27)  PipingComponentColor (PropID = 29)
'	28)  PipeKey (PropID = 30)
'	29)  CouplingKey (PropID = 31)
'	30)  StartFittingKey (PropID = 32)
'	31)  EndFittingKey (PropID = 33)
'	32)  Elbow90Key (PropID = 34)
'	33)  Elbow45Key (PropID = 35)
'	34)  SuppressStartFitting (PropID = 36)
'	35)  SuppressEndFitting (PropID = 37)
'	36)  UseSubASM (PropID = 38)
0 Likes