how to display only a part of a field in autocad

how to display only a part of a field in autocad

j.bongers
Enthusiast Enthusiast
2,941 Views
12 Replies
Message 1 of 13

how to display only a part of a field in autocad

j.bongers
Enthusiast
Enthusiast

In a block i have created a field which reads a custom dwg property, containing an article number as "011-210015"

Now I want to create another field in this block which returns only the last 4 caracters of this number, with trailing On, so in this case the number 15, if it was 011-210150 the number 150 etc.

 

I am trying a diesel expression but nothing seems to work.

What is the best way to do this?

0 Likes
Accepted solutions (1)
2,942 Views
12 Replies
Replies (12)
Message 2 of 13

hencoop
Advisor
Advisor

I think you can assign your target value to a variable (a little lisp) and then use the value of that variable to supply your field.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 3 of 13

JTBWorld
Advisor
Advisor

This Diesel expression takes the last 4 characters but for some reason only once. If you change the property and regen you will see that the field text is static.

Change "test" to the name of your custom property.

$(substr, %<\AcVar CustomDP.test>%, $(-, $(strlen, %<\AcVar CustomDP.test>%), 3))

 

So to really solve this you need a piece of AutoLISP reactor that saves the custom property as USERS1 and then have the Diesel like:

$(substr, $(getvar,USERS1), $(-, $(strlen, $(getvar,USERS1)), 3))

 

If you want help with that contact me directly or if you could have the article number in Excel you can use our app JTB Excel2TextField.


Jimmy Bergmark
JTB World - Software development and consulting for CAD and license usage reports
https://jtbworld.com

0 Likes
Message 4 of 13

cadffm
Consultant
Consultant

It you need it for users with ExpressTools installed, use RTEXT.

 

 

@JTBWorld 

It is what it is, simple rule: You can not nest a field inside an diesel field.

 

Sebastian

0 Likes
Message 5 of 13

Michiel.Valcke
Advisor
Advisor

Without any need for diesel expressions and lisp reactors you could divide your dwg property into several dwg properties and make the block attribute a combination of several fields each referring to a different property. If you want to represent part of that total value somewhere else you can directly refer to the separate dwg property that contains the value that you wish to represent.

Or check out this old forum post about a similar issue.

0 Likes
Message 6 of 13

j.bongers
Enthusiast
Enthusiast

I was more thinking of a way to mock up the field, so not by programming but by blinding off the first part.

That would be easier to do, but it seems that although Autocad has a lot of possibilities, they didn't think of that.

 

Jos.

0 Likes
Message 7 of 13

cadffm
Consultant
Consultant

It would works with a diesel expression, but there is no native diesel function to read dwgprops (and nested fields in diesel fields not possible).

The only way I know, see post #4, RTEXT.

Sebastian

0 Likes
Message 8 of 13

j.bongers
Enthusiast
Enthusiast

Ok, I have entered in RTEXT  $(getprop, %ART-1) where ART-1 is the drawing property with value 011-210015.

If it is possible to get the number 0015 I would be satisfied, but what should I have to enter behind ART-1 to get this?

 

Jos.

0 Likes
Message 9 of 13

cadffm
Consultant
Consultant

🤔 kidding me? 😁

 

first you asked for:

"011-210015" ==> "15"

"011-210315" ==> "315"

"011-214315" ==> "4315"

"Now I want to create another field in this block which returns only the last 4 caracters of this number, with trailing On,"

"so in this case the number 15, if it was 011-210150 the number 150 etc."

https://forums.autodesk.com/t5/autocad-forum/how-to-display-only-a-part-of-a-field-in-autocad/m-p/10...

 

I posted the solution in my hidden Link 😉 , read my post #4, and copy the link url from "use RTEXT" link.

 

 

And now you want "011-210015" => "0015" 🤔

but okay, it is also possible by remove the FIX part of my DieselExpression.

 

 

Have fun

Sebastian

0 Likes
Message 10 of 13

j.bongers
Enthusiast
Enthusiast

No, I am not kidding, but at some point I am doing what wrong, so I automatically assumed that 0015 would be easier.

Here is wat I get , the figure "-2" I have put behind your Diesel expression, because otherwise I cannot find it anymore on the drawing.

Kind Regards,

Jos.

jbongers_0-1643988560903.png

 

0 Likes
Message 11 of 13

cadffm
Consultant
Consultant

@j.bongers  schrieb:

 so I automatically assumed that 0015 would be easier.

That's right! But I already posted the solution for 15, 115 or 1115


 

The "-2" is to much!

 

It wasn't part of the link and not written in my PM,

I don't know from where the "-2" came?

 

again

$(fix,$(substr,$(getprop,%ART),$(-,$(strlen,$(getprop,%ART)),3),4))

for the version without leading zeros and


$(substr,$(getprop,%ART),$(-,$(strlen,$(getprop,%ART)),3),4)

for "the last 4 chars"

 

 

?

Sebastian

0 Likes
Message 12 of 13

cadffm
Consultant
Consultant

ahhh

I saw the other problem.

The link edited my Diesel-String, all "%" swaps to "%20%", oups.

 

I correct this in the post above, try it again with both DieselExpressions

and your Sample Art.Number *0015

*0215 and *6215

 

 

 

Sebastian

0 Likes
Message 13 of 13

j.bongers
Enthusiast
Enthusiast
Accepted solution

 

 

Marvelous...... this a good solution!!

 

Kind Regards,

 

Jos Bongers

0 Likes