Sekar Posted September 18 Author Share Posted September 18 Hi @BIGAL, I am not getting this., This is the output after placing text (001.png). But what i am looking is like this. (002.png) Can you explain a bit detail. Thanks Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 18 Share Posted September 18 (edited) Ok a few things for it to work you have to work in UCS WORLD. The text must exist within the cupboards, I also set it to z=0 When you select objects it also looks for the text within a new box containing all the parts. 2nd problem in new sample dwg you changed the name of the default layout I used Ph00. Can do a enter name but will leave that to you. The other option is can make layout names Ph01 Ph02 etc. I updated the code. ; https://www.cadtutor.net/forum/topic/78282-auto-fit-the-3d-drawings-in-the-each-viewport-of-each-layout/ (defun c:wow ( / box ss x ent tabn ans) (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already ;; Selection Set Bounding Box - Lee Mac ;; Returns a list of the lower-left and upper-right WCS coordinates of a ;; rectangular frame bounding all objects in a supplied selection set. ;; sel - [sel] Selection set for which to return bounding box (defun LM:bigbox (selobj / obj spc ) (if (setq box (LM:ssboundingbox selobj)) (progn (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) ) (if (equal 0.0 (apply '- (mapcar 'caddr box)) 1e-6) (progn (setq obj (vlax-invoke spc 'addlightweightpolyline (apply 'append (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) ((eval y) box)) x)) '( (caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr) ) ) ) ) ) (vla-put-closed obj :vlax-true) (vla-put-elevation obj (caddar box)) ) (apply 'vlax-invoke (vl-list* spc 'addbox (apply 'mapcar (cons '(lambda ( a b ) (/ (+ a b) 2.0)) box)) (apply 'mapcar (cons '- (reverse box))) ) ) ) ) ) (princ) ) (defun LM:ssboundingbox (sel / idx llp ls1 ls2 obj urp) (repeat (setq idx (sslength sel)) (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))) (if (and (vlax-method-applicable-p obj 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))) ) (setq ls1 (mapcar 'min (vlax-safearray->list llp) (cond (ls1) ((vlax-safearray->list llp)))) ls2 (mapcar 'max (vlax-safearray->list urp) (cond (ls2) ((vlax-safearray->list urp)))) ) ) ) (if (and ls1 ls2) (list ls1 ls2)) ) (setvar 'ctab "Model") (setq x (- (getint "\Enter start number ") 1)) (prompt "select a group of cupboards") (while (setq ss (ssget)) (LM:bigbox ss) (setq ent (entlast)) (setq pt1 (list (car (car box))(cadr (car box))) pt2 (list (car (cadr box))(cadr (cadr box)))) (setq ss2 (ssget "CP" (list pt1 pt2) '((0 . "*TEXT")))) (setq str (cdr (assoc 1 (entget (ssname ss2 0))))) (setq tabn (strcat "Ph" (rtos (setq x (1+ x)) 2 0))) (command "layout" "c" "Ph00" tabn) (setvar 'ctab tabn) (setq ans (ah:butts 1 "V" '("Choose 3d direction " "3d Front" "3d Back" "3d Left" "3d Right" "Front" "BacK" "Left" "Right"))) ; ans holds the button picked value as a string (command "Mspace") (cond ((= ans "3d Front")(command "vpoint" "-1,-1,1")) ((= ans "3d Back")(command "vpoint" "1,1,1")) ((= ans "3d Left")(command "vpoint" "1,1,1")) ((= ans "3d Right")(command "vpoint" "1,-1,1")) ((= ans "Front")(command "vpoint" "0,-1,0")) ((= ans "Back")(command "vpoint" "0,1,0")) ((= ans "Left")(command "vpoint" "-1,0,0")) ((= ans "Right")(command "vpoint" "1,0,0")) ) (setq pt1 (car box) pt2 (cadr box)) (setq mp (mapcar '* (mapcar '+ pt1 pt2)'(0.5 0.5 0.5))) (command "zoom" "c" mp 2000) (command "zoom" "OB" ent "") (command "erase" ent "") (command "pspace") (command "mtext" (list 10 185) (list 150 190) str "") (setvar 'ctab "Model") (prompt "select a group of cupboards Enter to exit ") ) ; sort tabs by CAB ;; 07/14/2005 CAB (setq cnt 1 doc (vla-get-activedocument (vlax-get-acad-object)) ) (foreach lay (acad_strlsort (vl-remove "Model" (layoutlist))) (vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt) (setq cnt (1+ cnt)) ) (princ) ) (c:wow) Edited September 18 by BIGAL Quote Link to comment Share on other sites More sharing options...
Sekar Posted September 18 Author Share Posted September 18 i am getting error ; error: bad argument type: lselsetp nil where i am making mistake? Quote Link to comment Share on other sites More sharing options...
Sekar Posted September 19 Author Share Posted September 19 hi @BIGAL 10 hours ago, Sekar said: i am getting error ; error: bad argument type: lselsetp nil where i am making mistake? can you help me on this? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 19 Share Posted September 19 (edited) Ok a couple of rules UCS W Plan Make sure mtext Z is zero use properties to reset. The master layout name is Ph00, we can discuss later different names. I changed code to check for text, (command "mtext" (list 10 185) (list 150 190) str "") change to (If (= str nil) (alert "no text label available ") (command "mtext" (list 10 185) (list 150 190) str "") ) Please try again. Edited September 19 by BIGAL Quote Link to comment Share on other sites More sharing options...
Sekar Posted September 19 Author Share Posted September 19 Hi., I tried it, but getting the same error, i placed the text in the Z=0, and within the specified area coordinates first corner at 10,185 and second corner at 150,190. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 19 Share Posted September 19 No the text gets placed in the cupboards see image. Quote Link to comment Share on other sites More sharing options...
Sekar Posted September 19 Author Share Posted September 19 (edited) Hi., if you dont mind can you make a short video on placement of text. i am not getting it. i am getting error only. ; https://www.cadtutor.net/forum/topic/78282-auto-fit-the-3d-drawings-in-the-each-viewport-of-each-layout/ (defun c:wow ( / box ss x ent tabn ans) (if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already ;; Selection Set Bounding Box - Lee Mac ;; Returns a list of the lower-left and upper-right WCS coordinates of a ;; rectangular frame bounding all objects in a supplied selection set. ;; sel - [sel] Selection set for which to return bounding box (defun LM:bigbox (selobj / obj spc ) (if (setq box (LM:ssboundingbox selobj)) (progn (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) ) (if (equal 0.0 (apply '- (mapcar 'caddr box)) 1e-6) (progn (setq obj (vlax-invoke spc 'addlightweightpolyline (apply 'append (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) ((eval y) box)) x)) '( (caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr) ) ) ) ) ) (vla-put-closed obj :vlax-true) (vla-put-elevation obj (caddar box)) ) (apply 'vlax-invoke (vl-list* spc 'addbox (apply 'mapcar (cons '(lambda ( a b ) (/ (+ a b) 2.0)) box)) (apply 'mapcar (cons '- (reverse box))) ) ) ) ) ) (princ) ) (defun LM:ssboundingbox (sel / idx llp ls1 ls2 obj urp) (repeat (setq idx (sslength sel)) (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))) (if (and (vlax-method-applicable-p obj 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))) ) (setq ls1 (mapcar 'min (vlax-safearray->list llp) (cond (ls1) ((vlax-safearray->list llp)))) ls2 (mapcar 'max (vlax-safearray->list urp) (cond (ls2) ((vlax-safearray->list urp)))) ) ) ) (if (and ls1 ls2) (list ls1 ls2)) ) (setvar 'ctab "Model") (setq x (- (getint "\Enter start number ") 1)) (prompt "select a group of cupboards") (while (setq ss (ssget)) (LM:bigbox ss) (setq ent (entlast)) (setq pt1 (list (car (car box))(cadr (car box))) pt2 (list (car (cadr box))(cadr (cadr box)))) (setq ss2 (ssget "CP" (list pt1 pt2) '((0 . "*TEXT")))) (setq str (cdr (assoc 1 (entget (ssname ss2 0))))) (setq tabn (strcat "Ph" (rtos (setq x (1+ x)) 2 0))) (command "layout" "c" "Ph00" tabn) (setvar 'ctab tabn) (setq ans (ah:butts 1 "V" '("Choose 3d direction " "3d Front" "3d Back" "3d Left" "3d Right" "Front" "BacK" "Left" "Right"))) ; ans holds the button picked value as a string (command "Mspace") (cond ((= ans "3d Front")(command "vpoint" "-1,-1,1")) ((= ans "3d Back")(command "vpoint" "1,1,1")) ((= ans "3d Left")(command "vpoint" "1,1,1")) ((= ans "3d Right")(command "vpoint" "1,-1,1")) ((= ans "Front")(command "vpoint" "0,-1,0")) ((= ans "Back")(command "vpoint" "0,1,0")) ((= ans "Left")(command "vpoint" "-1,0,0")) ((= ans "Right")(command "vpoint" "1,0,0")) ) (setq pt1 (car box) pt2 (cadr box)) (setq mp (mapcar '* (mapcar '+ pt1 pt2)'(0.5 0.5 0.5))) (command "zoom" "c" mp 2000) (command "zoom" "OB" ent "") (command "erase" ent "") (command "pspace") (If (= str nil) (alert "no text label available ") (command "mtext" (list 10 185) (list 150 190) str "") ) (setvar 'ctab "Model") (prompt "select a group of cupboards Enter to exit ") ) ; sort tabs by CAB ;; 07/14/2005 CAB (setq cnt 1 doc (vla-get-activedocument (vlax-get-acad-object)) ) (foreach lay (acad_strlsort (vl-remove "Model" (layoutlist))) (vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt) (setq cnt (1+ cnt)) ) (princ) ) (c:wow) Edited September 19 by Sekar Adding the code Quote Link to comment Share on other sites More sharing options...
Sekar Posted Friday at 01:59 AM Author Share Posted Friday at 01:59 AM On 9/20/2023 at 4:12 AM, BIGAL said: he text gets placed in the cupboards see image. how to place the text in the cupboards? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted Saturday at 04:25 AM Share Posted Saturday at 04:25 AM Again as Before UCS W PLAN Move the text to inside the cupboard. 1 Quote Link to comment Share on other sites More sharing options...
Sekar Posted Sunday at 09:36 AM Author Share Posted Sunday at 09:36 AM Hi @BIGAL., Thanks, it works in the bricscad. not in the autocad 2015. is is possible to set/ Change the text height in the layout? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted Sunday at 11:46 PM Share Posted Sunday at 11:46 PM (edited) It will be the default text size and style being used in the Mtext line. Mine was using 2.5 so did not see issue but did make it do weird things to the size and style. Look for the ctab line and add the 2 lines about setting text style and height. (setvar 'ctab "Model") (setvar 'textsize 2.5) (setvar 'textstyle "Text R") Edited Sunday at 11:59 PM by BIGAL Quote Link to comment Share on other sites More sharing options...
Sekar Posted Monday at 01:34 AM Author Share Posted Monday at 01:34 AM Hi @BIGAL, Thanks for helping me out patiently. Appreciated. It works. The text size has been updated. 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.