Dialog box in LISP as when using native commands

Dialog box in LISP as when using native commands

jw9VSWM
Explorer Explorer
876 Views
7 Replies
Message 1 of 8

Dialog box in LISP as when using native commands

jw9VSWM
Explorer
Explorer

Hi,

I'm using the native layout command in a LISP to control the folder destination. I have managed this somewhat via:

 

command "_.layout" "Template" selected-file

 

The first layout command gives me a pop-up window in the correct folder, but i get a textbox instead of a dialog box for layout choices. In other words. I would like the same effect as when using the button in the layout ribbon, not -layout "t".

0 Likes
Accepted solutions (1)
877 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

If I understand correctly:

(initdia)
(command "_.layout" "_template")

Kent Cooper, AIA
0 Likes
Message 3 of 8

jw9VSWM
Explorer
Explorer

It did not help with the (initdia) unfortunately.

 

Here is my code:

(defun c:LayoutTemplate ()

(command "filedia" "1")
(setq folder "C:/Program Files/company name ACAD/") ;define folder location

(setq selected-file (getfiled "Select a Template File" folder "dwt" 16)) ;select .dwt template

 

(if selected-file
   (progn
      (princ (strcat "\nSelected file: " selected-file))

      (initdia)
      (command "._layout" "_Template" selected-file "")
      (princ "\nLayout import complete."))
(princ "\nNo file selected."))

 

I would like to get the dialog box for "insert Layouts" (image attached) that you get when using the layout from template button in the ribbon.

 

Is this possible through lisp?

jw9VSWM_1-1726252881895.png

 

jw9VSWM_0-1726252865602.png

 

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

Try this:

 

(initcommandversion)

(command "._layout" "_Template" selected-file)

 

Or maybe:

 

(initcommandversion)

(command-s "._layout" "_Template" selected-file)

Kent Cooper, AIA
0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

This combo works.

 

(setvar 'filedia 0)

(initcommandversion)

(command "layout" ...)

 

Edit:  Not sure what's your ultimate goal, but I would prefer to use the built-in dialog over the getfile.

 

(defun c:LayoutTemplate ( / *error* o)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if o (setenv "TemplatePath" o))
    (princ))
  
  (setq o (getenv "TemplatePath"))
  (setenv "TemplatePath" "c:/FilePath/Template/")
  (initdia)
  (command-s "_.layout" "_t")
  (setenv "TemplatePath" o)
  (princ)
  )

 

0 Likes
Message 6 of 8

Sea-Haven
Mentor
Mentor

If you know the name of the layouts inside the template dwt, then it can be done very easy. 

 

If you have different DWT and hence different layout names then just use a cond to set the correct list of layout names.

SeaHaven_0-1726279284765.png

 

 

 

(if (not AH:Butts)(load "Multi radio buttons.lsp"))
(setq lst (list "please select " "A0_Landscape" "A1_Landscape" "A1_Portrait" "A2_Landscape" "A2_Portrait" "A3_Landscape"))
(setq layname (ah:butts 2 "V"  lst))

(command "layout" "T" masterlayouts  layname)
(setvar 'ctab  layname)
(command "pspace")

 

 

 

0 Likes
Message 7 of 8

paullimapa
Mentor
Mentor

another way to bring up file selection window is by using the symbol: ~

(command-s "_.layout" "_t" "~")

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 8

jw9VSWM
Explorer
Explorer
Worked like a charm.

(initcommandversion)
(command "._layout" "_Template" selected-file)
0 Likes