Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

if then else formula in a field or case then formula in a field

Jacques_V_
Contributor

if then else formula in a field or case then formula in a field

Jacques_V_
Contributor
Contributor

Hello,

Please we need the official Documentation about using formulas inside fields.

 

We have a field with page numbering, a Layer XX of YY Field. Render is "Page 01/50", "Page 02/50", ...

 

So we need Documentation and Examples about $if(condition,"case_1","case_2"), please.

 

Our Layer Tabs are named F-A3, F-A3 (2), F-A3 (3), etc. because in our Template we have only 1 layer, nammed F-A3 then we copy each layer to print further the drawing.

 

$(strlen,$(getvar,ctab)            Works shows length of string of current tab name

$(strlen,$(getvar,ctab),8)       Works shows length of string of current tab name, with useless parameter "8"

$(substr,$(getvar, ctab),7,1)   Works shows 1 caracter beginning at 7th caracter in current tab name

$(substr,$(getvar, ctab),7,2)   Works shows 2 caracters beginning at 7th caracter in current tab name

$(if,$(=,$(strlen,$(getvar,ctab),4),"case_1","case_2"))      X Doesn't work Should show "case_1" if current tab name length is "4" or else should show "case_2"

$(if,$(<,$(strlen,$(getvar,ctab),9),"case_1","case_2"))      X Doesn't work Should show "case_1" if current tab name length is less than "9" or else should show "case_2"

$(if,$(<,$(strlen,$(getvar,ctab),9),$(substr,$(getvar, ctab),7,1),$(substr,$(getvar, ctab),7,2)))           X Doesn't work Should show "1 caracter beginning at 7th caracter in current tab name" if current tab name length is less than "9" or else should show " 2 caracters beginning at 7th caracter in current tab name" . Example "2" out of "F-A3 (2)" else "12" out of "F-A3 (12)".

 

Finaly it would be nice to get total number of layer tabs (total number of pages) "Page $current tab/$count of tabs"). Currently we created a custom Total Count of Layers Property in Template then we mannually update it in each drawing. 

 

Regards

 

https://forums.autodesk.com/t5/image/serverpage/image-id/353923i104F2C57C37AC57C/image-size/small?v=v2&px=200https://forums.autodesk.com/t5/image/serverpage/image-id/353923i104F2C57C37AC57C/image-size/small?v=v2&px=200

 

0 Likes
Reply
Accepted solutions (2)
652 Views
5 Replies
Replies (5)

cadffm
Consultant
Consultant

Hi,

this is DIESEL and has nothing to do wie fields (but you can use it in Diesel-fields, of course).

DIESEL is documented [F1] , well enough for this basic stuff (just a help documentation. Not a tutorial)

 

Variable for total layouts and also current layout in order would be good, i am with you.

 

 

Sebastian

paullimapa
Mentor
Mentor

To get layout numbers as a field but using lisp the following thread may be of interest to you:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/page-numbering-for-layouts-using-fie...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

pendean
Community Legend
Community Legend
Accepted solution

@Jacques_V_ wrote:

Hello,

Please we need the official Documentation about using formulas inside fields....


FIELD command is covered in AutoCAD's HELP, I'll get you started with the online HELP version here

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-742C92C3-1284-4722-B650-C46F9191C701#:~:text=...  

 

DIESEL is what you are using and posting about though, which can be used in FIELDs and MTEXT and block ATTRIBUTES too. AutoCAD's HELP guidance is a good place to start, I'll help you out with an online link too, it starts here

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-76B3F3D3-6B9A-43E7-BE2C-D4B39AC3FBCF

 

HTH

Jacques_V_
Contributor
Contributor

Thank you all for your help.

 

So the direct link is :

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-F94A885A-4DA2-432B-AC1A-EB49CC6C1C72

 

An alternative link, with some minor differences is :

https://www.fourmilab.ch/diesel/

 

There and There I read :

$(if, expr, dotrue [, dofalse])

and 

$(IF,expr,dotrue,dofalse)

 

Then, I could solve :

 

Current Tab number (only if 8 or 9 caracters in the tab name, i.e. F-A3 (n) or F-A3 (nn) :

$(IF,$(=,$(strlen,$(getvar,ctab)),8),$(substr,$(getvar, ctab),7,1),$(substr,$(getvar, ctab),7,2))

 

Previous Tab number (current tab -1) :

$(-,1,$(IF,$(=,$(strlen,$(getvar,ctab)),8),$(substr,$(getvar, ctab),7,1),$(substr,$(getvar, ctab),7,2)))

 

Following Tab number (current tab +1) :

$(+,1,$(IF,$(=,$(strlen,$(getvar,ctab)),8),$(substr,$(getvar, ctab),7,1),$(substr,$(getvar, ctab),7,2)))

 

Thanks again,

 

Regards

0 Likes

TomBeauford
Collaborator
Collaborator
Accepted solution

I've used Lee Mac's code for this in building my layout template blocks https://lee-mac.com/layoutfield.html

I added a function just for the sheet number to the code and autoload it with acaddoc.lsp.

;|----------------------------------------------------------------------
  Layout Number

  Generates a field expression referencing the position of the layout in which the selected annotation object resides.
----------------------------------------------------------------------|;

(defun c:lfnumber ( )
    (layoutfield
       '(lambda ( obj )
            (vla-put-textstring obj
                (strcat
;                    "Sheet "
                    "%<\\AcObjProp Object(%<\\_ObjId "
                    (LM:objectid (layoutfield:layout obj))
                    ">%).TabOrder>%"
                )
            )
        )
    )
)

;|----------------------------------------------------------------------
  Total Sheets

 

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes