Define maxium length iproperty

Define maxium length iproperty

mcatalanbs
Explorer Explorer
285 Views
3 Replies
Message 1 of 4

Define maxium length iproperty

mcatalanbs
Explorer
Explorer

Hi everyone,

 

I want to know if it is possible to define the maxiium length of characteres in a custom iporperty.

I mean, I want to create a curstom iproperty and the maxium value text is 2 characters...

"My Descripticion"=MD

 

Thank you in advance

 

0 Likes
Accepted solutions (1)
286 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

If you want to check the length of a string or in other words how many characters use the Len string function. Official documentation is here 

 

Use

 

 

Dim CustomiProp as String = "MD"
'Check String Length
Messagebox.Show(Len(CustomiProp)

 

 

If you want to check each string value for length then you can build an if statement around the string function and insert into a larger function for repetitive use. If you need assistance on then please let us know. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

I don't think there is a elegant way to do this. But depending on your Inventor version you could create the following iLogic rule. Then trigger it on iProperty changes. (Inventor version is important because the trigger is not there in older versions of Inventor)  The problem with this method is that you will only get a messagebox after you have closed the iProperty dialog...

JelteDeJong_0-1666881986276.png

Dim myDescription = iProperties.Value("Custom", "My Descripticion")
If (myDescription.length > 2) Then
	MsgBox("iProperty 'My Descripticion' is to long. Will make it shorter for you!")
	iProperties.Value("Custom", "My Descripticion") = myDescription.Substring(0, 2)
End If

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 4

mcatalanbs
Explorer
Explorer

Thank you very much for your feedback!!

0 Likes