PDA

View Full Version : Limiting Field Length



crystalp
2009-01-06, 08:37 PM
Does anyone know if it possible to limit the number of characters in a field? I can't seem to find a way to do it. I want to link my drawing number to my drawing name with a field, but sometimes our drawing names get appended with other info that I don't want reflected in the drawing. Since our drawing numbers are always 6 characters, if I can set a limit to the field that will drop off anything over 6 characters that would be grand.

Thanks!

zoomharis
2009-01-08, 09:54 AM
Hi Crystal,
As I understand, you want to show a portion of the drawing file name as your drawing number. You can easily accomplish that using DIESEL expressions inside the field. When you use FIELD command, select field category as 'Other', then select 'DieselExpression' and write down the required expression in the right column provided over there. For your reference, the following DIESEL expression will show only the last 6 charecters of your drawing file name excluding the '.dwg' part.


$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),9),6)

For example, suppose your file name is XX-XX-123456.dwg, then the field will show only 123456.

HTH

irneb
2009-01-19, 12:01 PM
Unfortunately the Diesel field codes don't work with nested fields. While you can use Diesel expressions like getvar, placing a fieldcode inside the diesel expression (as you would in a formula) only puts a resulting text there - no live field.

mmh
2010-11-18, 01:56 AM
zoomharis,

Could you give me the code if I just want to show the first 3 letters of my drawing name?

Thanks,

mmh



Hi Crystal,
As I understand, you want to show a portion of the drawing file name as your drawing number. You can easily accomplish that using DIESEL expressions inside the field. When you use FIELD command, select field category as 'Other', then select 'DieselExpression' and write down the required expression in the right column provided over there. For your reference, the following DIESEL expression will show only the last 6 charecters of your drawing file name excluding the '.dwg' part.



For example, suppose your file name is XX-XX-123456.dwg, then the field will show only 123456.

HTH

irneb
2010-11-18, 05:28 AM
Congrats on your 1st post! Youv'e taken a while! ;)

The diesel code would be this:
$(substr,$(getvar,dwgname),1,3)Note the 1 states start copying from the 1st position in whatever string is passed into substr (in this case the string contained in the DWGNAME sysvar). The 3 states copy 3 characters.

mmh
2010-11-18, 06:29 PM
Awesome! works great and thanks for the explanation, was able to do some more tweaking.

mmh