Custom/user properties in view label of drawing template/style library?

Custom/user properties in view label of drawing template/style library?

Anonymous
Not applicable
12,099 Views
18 Replies
Message 1 of 19

Custom/user properties in view label of drawing template/style library?

Anonymous
Not applicable

Hi,

 

Is there a way that we can set the view label in the style library to show custom/user Properties?

 

We have set our iam/ipt templates to have some custom properites which we wish to display in the view label when the view is created however there this no way to add these properties to the label.

 

I find this a little strange as you can add these user Properties to the parts list in the style library? (I've added some screen caps to show what I am talking about)

 

Is there any way I can do this?

 

Cheers, Mick 

Accepted solutions (2)
12,100 Views
18 Replies
Replies (18)
Message 2 of 19

Curtis_Waguespack
Consultant
Consultant

Hi grinderz,

 

You can find some code to set an iProperty to the view label at this link:

http://inventortrenches.blogspot.com/2012/01/set-your-drawing-view-labels-to-use.html

 

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


 

 

EESignature

Message 3 of 19

Anonymous
Not applicable

Thanks Curtis for the reply & the link.

 

Just one more question with a yes/no/maybe answer Smiley Happy - can ilogic be used to not only change the Veiw name as per your link but to actually add custom/user properties into the view label text?

 

Cheers, Mick

0 Likes
Message 4 of 19

Curtis_Waguespack
Consultant
Consultant

Hi grinderz,

 

Here's a version that adds a custom iProperty to the existing view label. Note that the custom iProperty needs to exist in the model (or course).

 

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


 

'start of ilogic code
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
	'capture the current view label
	ViewLabel = oView.Name
	oModelName = _
	oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
	Try
	o_iProp = iProperties.Value(oModelName, "Custom", "My_iProp")	
	'add the the iProperty to the current view label, with a dash separator
	oView.Name = ViewLabel & " - " & o_iProp
        Catch
	'do nothing if error
	End Try
	Next
Next

'end of ilogic code

 

EESignature

Message 5 of 19

Anonymous
Not applicable

thanks again Curtis.

 

Sorry to be a pain but I guess I haven't explained myself very well or used the wrong terminology. I don't want to change the view label name but actually place custom properties in the view label text when the base view is created, please see attached - can this be done?

 

Cheers, Mick

 

 

0 Likes
Message 6 of 19

Curtis_Waguespack
Consultant
Consultant

Hi grinderz,

 

I see. I think I was just not reading carefully.

 

I didn't spend too much time on this but I did come up with a bit of a hack solution, that might work for you (but I sort of doubt it as it has a big flaw). But I'm going to post what I have and hope that someone else might jump in and provide the missing part.

 

The hack comes in two parts, first is just a rule that will get the custom iProperty ID and formatting from a view. So you'll want to edit your drawing view and add the custom iProperty to it as such:

 

Autodesk Inventor iLogic Custom Iproperty View Label 01.png

 

Then you can use this rule to get the ID and format for the custom iProperty:

 

'Get custom iProp format and ID from view label
'start of ilogic code
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
    'capture the current view label
    ViewLabel = oView.Label
    oModelName = _
    oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
    Try
    'return the value
    MessageBox.Show(oView.Label.FormattedText , "iLogic")
    'write the value to the drawings comments property
    iProperties.Value("Summary", "Comments") = oView.Label.FormattedText
    Catch
    'do nothing if error
    End Try
    Next
Next
'end of ilogic code

 

Then you can look in the drawings comments property and find the string to use in the next rule for that iProperty:

 

Autodesk Inventor iLogic Custom Iproperty View Label 02.png

 

So copy that string and enter it in this code, replacing the custom iProperty I have entered:

 

'Set View Label to use custom iProp 2
'start of ilogic code 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 'capture the current view label ViewLabel = oView.Label oModelName = _ oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName Try 'gets the custom iproperty from the model and formats it to be dynamic (uses <Br/> as a line break o_iProp_1= _ "<Property Document='model' PropertySet='User Defined Properties' Property='My_iProp_1' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='11'>My_iProp_1</Property><Br/>" 'add the the iProperty to the current view label, with a dash separator oView.Label.FormattedText = "<DrawingViewName/><Br/>" & o_iProp_1 Catch 'do nothing if error End Try Next Next 'end of ilogic code

 Repeat this if you have multiple custom iProperties to use and combine them in the formatted text line as such:

 

oView.Label.FormattedText = "<DrawingViewName/><Br/>"  &  o_iProp_1  &  o_iProp_2

You can remove "<DrawingViewName/><Br/>"  if you don't intend for the view label to use the view name.

Note too that <Br/> provides a line return.

 

I doubt this is really a solution becuase the custom iProperty could have a different ID number in different model files. For instance my example shows that My_iProp_1 has a PropertyID of 11 for the current part. But I might have another part where  My_iProp_1 has a PropertyID of 2.

 

So what is really needed is some code to return the property ID number and insert that into the string, so that the rule will work in all cases. I tried a couple of things with PropId but never did get the details worked out. I might get back to this later, but I thought this might help in the meantime.

 

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


 

EESignature

Message 7 of 19

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi grinderz,

 

Okay nevermind the previous post, I was able to get this sorted out. Here's the code and a couple of sample files.

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


 

'start of ilogic code
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_1 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_1").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
		oString1 = "<Property Document='model' PropertySet='User Defined Properties' " _
		&  "Property='My_iProp_1' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
		& o_iPropID_1  & "'>My_iProp_1</Property><Br/>"
		'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><Br/>"

		'add the custom iproperties to the view label
		oView.Label.FormattedText = "<DrawingViewName/><Br/>"  &  oString1 &  oString2
		Catch
		'do nothing if error
		End Try
	Next
Next
'end of ilogic code

 Autodesk Inventor Custom IProperties ilogic.png

 

 

Autodesk Inventor Custom IProperties ilogic_2.png

EESignature

Message 8 of 19

Anonymous
Not applicable

Hi Curtis,

 

Thanks so much for the solution and sample files, this is exactly what I was after and apreaciate the time you have spent.

 

Regards, Mick

0 Likes
Message 9 of 19

Anonymous
Not applicable

Is there a way I can get the projection orientation label as the "view" name without manually editing each label? 

0 Likes
Message 10 of 19

Anonymous
Not applicable

Hi,

 

I would like to know if it's possible to change iLogic code to change format text in arial 0.090pt and to apply the code just on projected views and not on all views.

 

Thanks a lot for your help

0 Likes
Message 11 of 19

cadman777
Advisor
Advisor

stephen,

 

Have you discovered a solution to this request?

 

Thanx

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 12 of 19

chrisw01a
Collaborator
Collaborator

This would be so much easier if we could just add a custom model iProperty to the view label defaults in the styles editor.

If the property exists, it shows up on the view, if not, then nothing happens.

 

Anyone from Autodesk know if this has ever been brought up?

 

Thanks

Chris

Message 13 of 19

cadman777
Advisor
Advisor

Chris,

I agree!

I raised this issue so many years ago, that I lost count. But apparently Adsk, in their infinite wisdom, requires their users to be able to write programs to do what they didn't implement in their Code.

Bottom line: Development resources have not been adequately allocated to developing Inventor over the past decade.

 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 14 of 19

cadman777
Advisor
Advisor

Chris,

In my condemnation of Adsk, I totally forgot about the WORKAROUND I use, so here it is:

https://forums.autodesk.com/t5/inventor-customization/automated-view-annotation-styles-for-sheet-met...

Hopefully this will help.

Basically, you're recycling your custom iprop into an unused default iprop.

Cheers 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 15 of 19

Anonymous
Not applicable

How to modify the code in answer 4 to apply only to one View?

0 Likes
Message 16 of 19

WCrihfield
Mentor
Mentor

Hi @Anonymous.  I don't know if you still needed this or not, but here is an equivalent to the code in message 4, but which applies to only 1 view.  However, this simply works with the first view found on the active sheet.

oDDoc = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
'specify which view to work with
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
'get model document being represented in that view
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
'get file name (without path, but with file extension)
'oModelName = oModel.DisplayName 'Read/Write
oModelName = System.IO.Path.GetFileName(oModel.FullFileName)
Try
	oVal = iProperties.Value(oModelName, "Custom", "My_iProp")	
	oView.Name = oView.Name & " - " & oVal
Catch
	'do nothing if error
End Try

However, if you want to be able to specify the name of the view to target, we would have to change a few things.  There are several ways to get a drawing view by its name, but it requires more code to do so.  Here is likely the simplest way (least amount of code), which uses an iLogic snippet to replace the first 3 lines.

oView = ActiveSheet.View("VIEW1").View
'get model document being represented in that view
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
'get file name (without path, but with file extension)
'oModelName = oModel.DisplayName 'Read/Write
oModelName = System.IO.Path.GetFileName(oModel.FullFileName)
Try
	oVal = iProperties.Value(oModelName, "Custom", "My_iProp")	
	oView.Name = oView.Name & " - " & oVal
Catch
	'do nothing if error
End Try

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 17 of 19

ArunRajan_TC
Explorer
Explorer

Hi, Can someone help me with i logic to update all the view labels in all sheets of drawing to match following format
<VIEW IDENTIFIER> <TITLE><DELIM><PARENT SHEET NAME> <SCALE>

0 Likes
Message 18 of 19

ArunRajan_TC
Explorer
Explorer

Hi, Can someone help me with i logic to update all the view labels in all sheets of drawing to match following format
<VIEW IDENTIFIER> <TITLE><DELIM><PARENT SHEET NAME> <SCALE>

0 Likes
Message 19 of 19

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ArunRajan_TC.  The "<TITLE>" portion of that is ambiguous, because it does not specify whether it is getting that information from 'the model', or 'the drawing'.  So, I assumed it was supposed to be obtained from the drawing, when creating this code example for you to try out.  If you want to figure out how to do this on your own, you can review the XML Tags for FormattedText online help page, as one resource.  And you can also format the drawing view label the way you want it to be, manually, then 'inspect' the contents of its 'FormattedText' afterwards using a relatively simple iLogic rule that lets you manually pick that DrawingViewLabel object with your mouse, then report its contents, one way or another.  Other than that, it's really pretty complicated to do by code.

Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oASheet As Inventor.Sheet = oDDoc.ActiveSheet
	Dim sFText As String = "<DrawingViewName/> " & _
	"<Property Document='drawing' PropertySet='Inventor Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property>" & _
	"<Delimiter/>" & _
	"<DrawingViewParentSheetName/> " & _
	"<DrawingViewScale/>"
	For Each oSheet As Inventor.Sheet In oDDoc.Sheets
		For Each oView As DrawingView In oSheet.DrawingViews
			If Not oView.ShowLabel Then oView.ShowLabel = True
			Dim oVLabel As DrawingViewLabel = oView.Label
			Try
				oVLabel.FormattedText = sFText
			Catch oEx As Exception
				Logger.Error("Error setting DrawingViewLabel.FormattedText:" _
				& vbCrLf & oEx.ToString)
			End Try
		Next oView
		'oSheet.Update
	Next oSheet
	oDDoc.Update2(True)
End Sub

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

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)