autocad

Autocad Diesel IF expression for sheet number tag


I am trying to automate a sheet tag with a Diesel expression in AutoCad.

This gets me the twelfth character in the drawing name. But as soon as I get to sheet 10 this will say its sheet 0.

$(substr,$(getvar,dwgname),12,1)

Does anyone know a way to get an If statement to see if the eleventh character is a 0 then run the above code else run $(substr,$(getvar,dwgname),11,2)

This is something i have tried. $(IF,substr,$(getvar,dwgname),11,1)="0"$(substr,$(getvar,dwgname),11,2,substr,$(getvar,dwgname),12,1)

This appears to be similar to excel formulas. Thanks for any help.


Solution

  • Here is the Diesel expression i got working for auto sheet no. in autocad fields.

    $(if,$(substr,$(getvar,dwgname),11,1)"0",$(substr,$(getvar,dwgname),11,2),$(substr,$(getvar,dwgname),12,1))

    $(if,$(substr,$(getvar,dwgname),11,1)"0" = Does character 11 = 0 ,$(substr,$(getvar,dwgname),11,2) = if no then take character 11 and the next char. ,$(substr,$(getvar,dwgname),12,1)) = if char 11 is = to 0 then take only char 11.

    I use two fields in my autocad border. One for the filename without the sheet no and this one for only the sheet number.

    Example filename: A150225_S001.dwg

    $(substr,$(getvar,dwgname),1, 7) = Use char from position 1 to 7. "A150225"

    $(if,$(substr,$(getvar,dwgname),11,1)"0",$(substr,$(getvar,dwgname),11,2),$(substr,$(getvar,dwgname),12,1)) = Use sheet no. at end of filename string. "1"

    Hope this helps anyone looking to do something similar.