Inventor Customization

Inventor Customization

Reply
Active Member
grinderz
Posts: 10
Registered: ‎01-14-2008
Message 1 of 10 (3,232 Views)
Accepted Solution

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

3232 Views, 9 Replies
04-18-2012 08:32 PM

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 

*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 2 of 10 (3,191 Views)

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

04-19-2012 08:07 AM in reply to: grinderz

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


 

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
grinderz
Posts: 10
Registered: ‎01-14-2008
Message 3 of 10 (3,179 Views)

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

04-19-2012 07:24 PM in reply to: Curtis_Waguespack

Thanks Curtis for the reply & the link.

 

Just one more question with a yes/no/maybe answer :smileyhappy: - 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

*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 4 of 10 (3,169 Views)

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

04-20-2012 08:15 AM in reply to: grinderz

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

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
grinderz
Posts: 10
Registered: ‎01-14-2008
Message 5 of 10 (3,139 Views)

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

04-22-2012 05:25 PM in reply to: Curtis_Waguespack

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

 

 

*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 6 of 10 (3,122 Views)

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

04-23-2012 12:58 PM in reply to: grinderz

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


 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 7 of 10 (3,116 Views)

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

04-23-2012 02:33 PM in reply to: Curtis_Waguespack

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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
grinderz
Posts: 10
Registered: ‎01-14-2008
Message 8 of 10 (3,105 Views)

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

04-23-2012 03:51 PM in reply to: Curtis_Waguespack

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

Active Member
jbauer
Posts: 8
Registered: ‎04-25-2012
Message 9 of 10 (3,063 Views)

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

04-25-2012 01:25 PM in reply to: grinderz

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

New Member
stephaniedeslandes
Posts: 1
Registered: ‎08-25-2014
Message 10 of 10 (67 Views)

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

08-25-2014 01:51 PM in reply to: Curtis_Waguespack

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.