adrath Posted October 28 Share Posted October 28 Hey all! I'm working on creating my own version of a LISP routine I used at a previous employer that would allow the user to place a multi-leader rotated to the current view. In my field, we use a lot a twisted views (we have a LISP routine that is basically a shortcutted version of Dview Twist that we use to set views) to make our linework fit neatly on our sheets, so this has a lot of utility for me. Essentially, what I want this routine to do is: 1.Set the UCS to view 2. Invoke the MLEADER command 3. Pause while the user places the callout and 4. Set the UCS back to Previous before exiting. I know next to nothing about LISP as a programming language, so I've been using MicroSoft CoPilot (and some older posts on this forum I've pulled up on Google) to try to put this code together. Here's what I have: (defun c:MLR () (command "UCS" "VIEW") ; Set UCS to view (command "MLEADER") ; Invoke Multileader command (while (= 1 (getvar "CMDACTIVE")) (command pause)) ; Pause until the user completes the Multileader command (command "UCS" "P") ; Set UCS to previous (princ) ) This works really well, except that I can't enter contents of the multi-leader. It just always fills out a / for me and I'd have to go back and double-click and edit it. Can anyone tell me how to get it to let me fill out the text? Is it the Pause command that's causing the problem? Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 28 Share Posted October 28 Just a comment we used UCS S name so would give each ucs a name, like road1, road2 etc We would make these using UCS OB selecting a object to align the UCS, then save it. UCS R is reset to a saved UCS. UCS W is to world. I just did a UCS and Mleader no probs. You can set how many lines in the leader so would have a style for say 2 or 3. Then it will ask for text once correct number of points are selected. Quote Link to comment Share on other sites More sharing options...
adrath Posted October 29 Author Share Posted October 29 13 hours ago, BIGAL said: Just a comment we used UCS S name so would give each ucs a name, like road1, road2 etc We would make these using UCS OB selecting a object to align the UCS, then save it. UCS R is reset to a saved UCS. UCS W is to world. I just did a UCS and Mleader no probs. You can set how many lines in the leader so would have a style for say 2 or 3. Then it will ask for text once correct number of points are selected. If I understand you correctly, I need to add a Command Pause for each different click. Our leaders are set to have a max number of 2 points, so there should be 3 total pauses, one for each click and then one for text entry. I tried that, and this is what happened in the command line: For some reason, under text it's just putting a "\" and I never even get the option to enter the text editor. Everything else works, I just have to hit enter after placing the leader to reset the UCS. But I can't for the life of me figure out where the "\" in the multileader text is coming from. Here's the code after I added pauses: (defun c:MLR () (command "UCS" "VIEW") ; Set UCS to view (command "MLEADER") ; Invoke Multileader command (while (= 1 (getvar "CMDACTIVE")) (command pause) (command pause) (command pause)) ; Pause until the user completes the Multileader command (command "UCS" "P") ; Set UCS to previous (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted Tuesday at 10:16 PM Share Posted Tuesday at 10:16 PM Maybe something like this. ; single line leader using standard (defun c:mlr2 ( / ) (setvar 'CMLEADERSTYLE "Standard") (command "VIEW" "R" "View") (command "mleader" pause pause pause) (command "Ucs" "W" "PLAN" "") ) Quote Link to comment Share on other sites More sharing options...
adrath Posted Thursday at 03:22 PM Author Share Posted Thursday at 03:22 PM On 10/29/2024 at 5:16 PM, BIGAL said: Maybe something like this. ; single line leader using standard (defun c:mlr2 ( / ) (setvar 'CMLEADERSTYLE "Standard") (command "VIEW" "R" "View") (command "mleader" pause pause pause) (command "Ucs" "W" "PLAN" "") ) That works perfectly, except that it still doesn't enter the text editor it just places a /. I've tried to change the invoke leader line to "MLEADER" "T" to force it to place the text first but it just freezes my CAD when I do that. I wonder if my company has a system variable set that is screwing with how the multi-leaders work. Quote Link to comment Share on other sites More sharing options...
pkenewell Posted Friday at 02:42 PM Share Posted Friday at 02:42 PM (edited) On 10/31/2024 at 11:22 AM, adrath said: That works perfectly, except that it still doesn't enter the text editor it just places a /. I've tried to change the invoke leader line to "MLEADER" "T" to force it to place the text first but it just freezes my CAD when I do that. I wonder if my company has a system variable set that is screwing with how the multi-leaders work. @adrath Unfortunately, the MLEADER text editor doesn't work within the (command) function. The only way I know to do it is to emulate the MLEADER prompts and then run the command after. Try this code: ;; Written by PKenewell - 11/1/2024 (defun c:mlr (/ *error* an ar oec p p1 p2 p3 p4 pt pts s sl) (defun *error* (msg) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*quit*,*exit*")) (princ (strcat "\nError: " msg "\n")) (princ "\nProgram Aborted.\n") ) (command-s) (command-s "._ucs" "_p") (command-s "._undo" "_End") (if oec (setvar "cmdecho" oec)) ) (setq oec (getvar "cmdecho")) (setvar "cmdecho" 0) (command "._undo" "_be") (command "._ucs" "_view") (if (and (setq p1 (getpoint "\nSelect start point of MLEADER: ")) (setq p2 (getpoint p1 "\nSelect next point of MLEADER: ")) ) (progn (setq ar (* (getvar "dimscale") (getvar "dimasz")) an (angle p1 p2) p (polar p1 an ar) p3 (polar p (+ (/ pi 2) an) (/ ar 6)) p4 (polar p (+ (* pi 1.5) an) (/ ar 6)) ) (grdraw p1 p2 -1) (grdraw p1 p3 -1) (grdraw p1 p4 -1) (grdraw p3 p4 -1) (setq pts (list p1 p2)) (while (setq pt (getpoint (last pts) "\nSelect next point of MLEADER: ")) (grdraw (last pts) pt -1) (setq pts (append pts (list pt))) ) (while (/= "" (setq s (getstring t "\nEnter Text: "))) (setq sl (append sl (list s))) ) (command "._mleader") (foreach p pts (command p)) (command "") (if sl (progn (setq sl (apply 'strcat (cons (car sl)(mapcar '(lambda (x) (strcat "\\P" x)) (cdr sl))))) (command sl) ) (command) ) (redraw) ) ) (command "._ucs" "_p") (command "._undo" "_End") (setvar "cmdecho" oec) (princ) ) EDIT: Added an error handler and added a couple variables for grdraw points to make it easier to follow. Edited Friday at 03:26 PM by pkenewell Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.