Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to truncate an iproperty for use as a view label in an Inventor drawing.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
537 Views, 5 Replies

How to truncate an iproperty for use as a view label in an Inventor drawing.

Anonymous
Not applicable

I would like to use the P/N as part of my view label.  However, I need to truncate the characters shown.  (see attachment)

 

Regarding attachment:

    -first snippet is of my label formatting

    -second snippet is current results

    -third snippet is desired results

 

thanks in advance for any help.

0 Likes

How to truncate an iproperty for use as a view label in an Inventor drawing.

I would like to use the P/N as part of my view label.  However, I need to truncate the characters shown.  (see attachment)

 

Regarding attachment:

    -first snippet is of my label formatting

    -second snippet is current results

    -third snippet is desired results

 

thanks in advance for any help.

5 REPLIES 5
Message 2 of 6
Curtis_Waguespack
in reply to: Anonymous

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous,

 

I think you'd need to use a bit of iLogc code, to do this. Would you want all of the views on the sheet to be updated? Or just select one view at a time?

 

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

0 Likes

Hi @Anonymous,

 

I think you'd need to use a bit of iLogc code, to do this. Would you want all of the views on the sheet to be updated? Or just select one view at a time?

 

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

Message 3 of 6
Anonymous
in reply to: Curtis_Waguespack

Anonymous
Not applicable

I would prefer to update one view at a time.

 

thanks

0 Likes

I would prefer to update one view at a time.

 

thanks

Message 4 of 6
Curtis_Waguespack
in reply to: Anonymous

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous,

 

Here is a quick iLogic rule to do this:

 

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("You must select a drawing view first", "iLogic")
	Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
	oView.ShowLabel = True
	
	
	'get the part number from the model in the view
	oPN = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oPartNumber = "<StyleOverride Underline='True'>" & oPN & "</StyleOverride>"
	
	'set temp view label
	oView.Label.FormattedText = oPartNumber
	'add ITEM and get last 2 digits
	oPN2 = "ITEM " & Right(oView.Label.Text,2)
	
	'format text for view label
	oPartNumber = "<StyleOverride Underline='True'>" & oPN2 & "</StyleOverride>"
	oStringScale = "<Br/><StyleOverride Underline='False'>" & "SCALE <DrawingViewScale/>" & "</StyleOverride>"
	oDescription = "<Br/><StyleOverride Underline='False'>" & _
	"<Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
	
	
	'add to the view label
	oView.Label.FormattedText = oPartNumber & oDescription & oStringScale
Else
	MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

related link:

https://forums.autodesk.com/t5/inventor-customization/ilogic-code-to-change-view-label-text/td-p/3625130

 

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

0 Likes

Hi @Anonymous,

 

Here is a quick iLogic rule to do this:

 

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("You must select a drawing view first", "iLogic")
	Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
	oView.ShowLabel = True
	
	
	'get the part number from the model in the view
	oPN = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oPartNumber = "<StyleOverride Underline='True'>" & oPN & "</StyleOverride>"
	
	'set temp view label
	oView.Label.FormattedText = oPartNumber
	'add ITEM and get last 2 digits
	oPN2 = "ITEM " & Right(oView.Label.Text,2)
	
	'format text for view label
	oPartNumber = "<StyleOverride Underline='True'>" & oPN2 & "</StyleOverride>"
	oStringScale = "<Br/><StyleOverride Underline='False'>" & "SCALE <DrawingViewScale/>" & "</StyleOverride>"
	oDescription = "<Br/><StyleOverride Underline='False'>" & _
	"<Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
	
	
	'add to the view label
	oView.Label.FormattedText = oPartNumber & oDescription & oStringScale
Else
	MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

related link:

https://forums.autodesk.com/t5/inventor-customization/ilogic-code-to-change-view-label-text/td-p/3625130

 

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

Message 5 of 6
Anonymous
in reply to: Curtis_Waguespack

Anonymous
Not applicable

Thanks Curtis!  That works great.  I do have one last request...

Is it possible to have the first line of text height be at .18 in and the next two lines be at .125 in?

 

I appreciate your assistance.

 

Tim

Thanks Curtis!  That works great.  I do have one last request...

Is it possible to have the first line of text height be at .18 in and the next two lines be at .125 in?

 

I appreciate your assistance.

 

Tim

Message 6 of 6
Curtis_Waguespack
in reply to: Anonymous

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Anonymous,

 

Try this version. Note that the Font Size numbers are in centimeters.

 

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

 

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("You must select a drawing view first", "iLogic")
	Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
	oView.ShowLabel = True
	
	
	'get the part number from the model in the view
	oPN = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oPartNumber = "<StyleOverride Underline='True'>" & oPN & "</StyleOverride>"
	
	'set temp view label
	oView.Label.FormattedText = oPartNumber
	'add ITEM and get last 2 digits
	oPN2 = "ITEM " & Right(oView.Label.Text,2)
	
	'format text for view label
	oPartNumber = "<StyleOverride Underline='True' FontSize=' 0.4572'>" & oPN2 & "</StyleOverride>"
	oStringScale = "<Br/><StyleOverride Underline='False' FontSize=' 0.3175' >" & "SCALE <DrawingViewScale/>" & "</StyleOverride>"
	oDescription = "<Br/><StyleOverride Underline='False' FontSize=' 0.3175'>" & _
	"<Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
	
	
	'add to the view label
	oView.Label.FormattedText = oPartNumber & oDescription & oStringScale
Else
	MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

Hi @Anonymous,

 

Try this version. Note that the Font Size numbers are in centimeters.

 

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

 

Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("You must select a drawing view first", "iLogic")
	Exit Sub
End If

'Reference to the drawing view from the 1st selected object
Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)

If oView IsNot Nothing Then
	oView.ShowLabel = True
	
	
	'get the part number from the model in the view
	oPN = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>PART NUMBER</Property>"
	oPartNumber = "<StyleOverride Underline='True'>" & oPN & "</StyleOverride>"
	
	'set temp view label
	oView.Label.FormattedText = oPartNumber
	'add ITEM and get last 2 digits
	oPN2 = "ITEM " & Right(oView.Label.Text,2)
	
	'format text for view label
	oPartNumber = "<StyleOverride Underline='True' FontSize=' 0.4572'>" & oPN2 & "</StyleOverride>"
	oStringScale = "<Br/><StyleOverride Underline='False' FontSize=' 0.3175' >" & "SCALE <DrawingViewScale/>" & "</StyleOverride>"
	oDescription = "<Br/><StyleOverride Underline='False' FontSize=' 0.3175'>" & _
	"<Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
	
	
	'add to the view label
	oView.Label.FormattedText = oPartNumber & oDescription & oStringScale
Else
	MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If

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

Post to forums  

Autodesk Design & Make Report