Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
adragroup
10492 Views, 15 Replies

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

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 

15 REPLIES 15
Message 2 of 16

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


 

 

Message 3 of 16

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

Message 4 of 16

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

 

Message 5 of 16

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

 

 

Message 6 of 16

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


 

Message 7 of 16

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

Message 8 of 16

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

Message 9 of 16
jbauer
in reply to: adragroup

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

Message 10 of 16

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

Message 11 of 16

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
Message 12 of 16
chrisw01a
in reply to: cadman777

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 16
cadman777
in reply to: chrisw01a

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
Message 14 of 16
cadman777
in reply to: cadman777

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
Message 15 of 16
awt2001
in reply to: adragroup

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

Message 16 of 16
WCrihfield
in reply to: awt2001

Hi @awt2001.  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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report