Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Diesel Expressions

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
4028 Views, 3 Replies

Diesel Expressions

Can anyone give me a quick breakdown of some Diesel language? I use $(getvar,ctab) quite often in my titleblocks, but sometimes the customer wants different things displayed (like only the first 4 characters). Up until now I've usually been able to find a similar answer on one forum or another, but I would really like to understand what the code means, and what it's doing. 

 

$(substr,$(getvar,ctab),5,$(strlen,$(getvar,ctab)))

 

Here is one I used recently to get everything past the first 4 characters. I have gathered that it's starting at character "5", but can someone explain the rest? If anyone would be willing to give me an example or two that pull from different parts of the tab name and break down what it means I would REALLY appreciate it! Thanks!

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: Anonymous

Help is your friend.  Here [for 2017, but I don't imagine it's changed] is the Customization Guide.  About halfway down is the Diesel area.

 

For your particular example, I wonder....  I don't use Diesel much, but it's similar in many ways to AutoLisp except for the dollar signs that aren't in Lisp, and the commas that are spaces in Lisp, and no quoting of System Variable names as one does in Lisp.  So that Diesel expression looks like it would be equivalent to this in Lisp:

 

(substr (getvar 'ctab) 5 (strlen (getvar 'ctab)))

 

If that's really equivalent, the latter part [after the 5] is pointless.  It's saying "Get a substring from the CTAB System Variable, starting at character 5 and continuing for the number of characters in CTAB."  That asked-for length would, of course, carry beyond the end of that string, so it would just get from character 5 to the end.  In Lisp, you can go all the way to the end simply by not specifying how many characters you want, but specifying only the starting one:

 

(substr (getvar 'ctab) 5)

 

So [again, if there's really equivalence here], the Diesel equivalent of that should be simply:

 

$(substr,$(getvar,ctab),5)

 

which I expect would get you exactly the same result as your example.  But others more versed in Diesel can correct me....

Kent Cooper, AIA
Message 3 of 4
Anonymous
in reply to: Kent1Cooper

Thank you for your help! That customization guide is what I've been searching for for some time now!

Message 4 of 4
Anonymous
in reply to: Anonymous

$(substr,$(getvar,DWGNAME),27,$(-,$(strlen,$(getvar,DWGNAME)),34))

 

I need status field to change on the drawing (title block) as I save as:

original drawing name 0000-bbbb-xx-yy-dr-s-0000.dwg

save as:                        0000-bbbb-xx-yy-dr-s-0000-S3-P01.dwg 

Diesel Expression can get me the S3 with an insert field

BUT on the original drawing can S3 be converted to S0 ?!!

I tried two diesel expressions... (not working) I think I need an add on to the expression below if the drawing name is shorter.

 

Any ideas?!!!

Thank you in advance.

 

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

Post to forums  

Forma Design Contest


AutoCAD Beta