Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pause to allow user to select layout tab

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
ghlad
556 Views, 10 Replies

Pause to allow user to select layout tab

Sorry couldn't find the answer to this.  I need a command that will allow the user to select a layout tab.  I thought the following would work, but it just ends the LISP program:

 

(command "layout" "s" pause)

 

Thanks in advance!

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
10 REPLIES 10
Message 2 of 11
Lee_Mac
in reply to: ghlad

To my knowledge, selecting a layout tab will cancel any LISP program (unless the user enters the layout name at the command-line to switch).

 

How about using my ListBox function from here called with:

 

(LM:ListBox "Select Layout" (layoutlist) nil)

 

Message 3 of 11
ghlad
in reply to: Lee_Mac

That worked great!  Thanks Lee Mac!

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
Message 4 of 11
Lee_Mac
in reply to: ghlad

Excellent Smiley Happy  You're welcome!

Message 5 of 11
ghlad
in reply to: Lee_Mac

Lee,

 

Thanks again for your considerable help.  I attached the program I wrote that includes your LM:FieldString and LM:ListBox routines.  The program modifies the sheet number in the paper space border to match the sheet number in the layout tab.  I use fields with user variable 1-5 to update sheet numbers.  This program is used one time in the initial set up of sheets for a project so that the last number in the diesel expression $(+, $(getvar, useri2), 0) can be modified by +1 for each layout.  I wrote a copy layout tab routine that updates tab sheet numbers and could have updated a simple text string in the border sheet, but I like the simplicity of user variables to update sheet numbers throughout the life cycle of a project (with all the revisions that happen). 

 

The program is not fully tested and makes a lot of untested assumptions.  I just wanted to see if the concept could work.  Also, it seems to work well sometimes and then fail on the next test.  Not sure if there are variables not being zeroed out or what.  I would appreciate it if you had a minute to look it over.  Thanks again for your help!

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
Message 6 of 11
ghlad
in reply to: Lee_Mac

Lee,

 

One other curious thing: my program ignores any prompts immediately before your LM:ListBox routine.  I can't figure out why.  See below (I commented out the line being ignored and revised the title of the list box to also be the user prompt):

 

(if (= response "No")
  (progn
   ;(prompt "\nPick first layout tab to match: ")
 (setq ftab
   (nth 0
     (LM:ListBox "Select first layout to match:" (layoutlist) nil)
   )
 )
 (setvar "ctab" ftab)
  )
  (setq ftab (getvar "ctab"))
)

 

Thanks!

Greg

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
Message 7 of 11
Lee_Mac
in reply to: ghlad

I don't have time to look over your complete program, but in regard to your last post, consider:

 

(defun c:test ( / ftab )
    (prompt "\nPick First Layout Tab to Match: ")
    (princ) ;; Force screen update

    (if (setq ftab (car (LM:ListBox "Select First Layout to Match" (layoutlist) nil)))
        (setvar 'CTAB ftab)
        (princ "\n*Cancel*")
    )
    (princ)
)

 

Remember to use a conditional statement to allow for the user pressing Cancel on the dialog. Also note that (nth 0 nil) will error.

Message 8 of 11
ghlad
in reply to: Lee_Mac

Thanks for the suggestions, Lee.  I revised the program to include an exit from the program when the user selects Cancel.  And the prompts now work!  Also, the program is working consistently today.  After so many revisions yesterday, AutoCAD probably needed a restart.  Thanks for your help!  (revised attachment)

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
Message 9 of 11
Lee_Mac
in reply to: ghlad

I've just noticed that you replied to your other thread after I posted the FieldString function, I apologise that I didn't see your reply (I didn't frequently participate on this forum and haven't worked out how to check new replies as yet).

 

Anyway, I found some time to take a look at your code, I have attached a modified version for your perusal - I would appreciate if you could return the courtesy and take some time to study my modifications.

 

First thing I noticed is that you are not localising your variables - this could explain the inconsistent results you have witnessed when repeatedly testing the routine since global variables remain in the active document namespace until the drawing is closed and the namespace destroyed, effectively clearing the all values bound to variable symbols. To get a better understanding as to the reasons for variable localisation, have a read of my tutorial here.

 

I have condensed the code quite considerably, but in doing so I may have misunderstood your intentions. The attached code now only requires my 'ListBox' function. I haven't tested the attached code, so there may well be some typos lurking therein.

 

I apologise for removing many of your comments, but I find code a lot easier to read without comments - some may think this is bad practice, but with structured code, I think the program is effectively self-documenting.

 

Hope this helps,

 

Lee

Message 10 of 11
ghlad
in reply to: Lee_Mac

Lee, 

I just tested your version of my program and it does exactly what I intended with mine, only with a fraction of the code!  Brilliant!  I am humbled by your awesomeness.  Thank you for taking time to do that.  As a new LISP programmer it will take me some time to figure out how you made that work.  (I have to admit when I first looked at the code - before testing - I didn't think it would do what I wanted.  Glad it does!)

 

Thanks!

Greg

Greg

Civil 3D 2020
Windows 10 Pro
Intel Core i7 @ 3.20 GHz
64-bit OS 16 GB RAM

"What sane person could live in this world and not be crazy?" Ursula K. Le Guin, brainyquote.com
Message 11 of 11
Lee_Mac
in reply to: ghlad

Thank you for your kind compliments Greg, I'm glad that the program performs as required. I may have inadvertently let you follow a rather drawn-out method with regards to my FieldString code in your other thread, having not fully understood what you were trying to accomplish (I initially thought the field expressions would be different for each entity); but hopefully you have gained a deeper understanding of the structure of field expressions along the way.

 

I would recommend you use the Visual LISP IDE provided with AutoCAD to view/dissect the code, and use the direct link to the function reference (see here) to look up anything you don't know. If you have any questions about any of the code I have posted, don't hesitate to ask and I shall try my best to put together a comprehensible explanation.

 

Cheers,

 

Lee

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

Post to forums  

Autodesk Design & Make Report

”Boost