CadFrank Posted October 17, 2012 Posted October 17, 2012 Hello, Can't seem to change the width og my retangle and this is what i tried. (setq ent(entlast)) (setq sel(ssget ent)) (setq ent (entget ent)) (setq oldlist (assoc 43 ent)) (setq conlist (cons(car ancliste) 18.0)) (setq newlist (subst conlist oldlist ent)) (entmod ent) and it gives me the error : ; error: bad DXF group: nil what am I doing wrong ? Quote
Lee Mac Posted October 17, 2012 Posted October 17, 2012 The variable ancliste is not defined in your code, resulting in the DXF group (nil . 18.0) hence causing the error: bad DXF group nil. In addition, there is no need for the ssget expression, and you are also using entmod with the old DXF data list bound to the ent variable, and not the modified DXF data. Consider the following code: (setq ent (entget (entlast))) ent (subst '(43 . 18.0) (assoc 43 ent) ent) ) (entmod ent) Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 Thanks Lee, It works, now i'm trying to make it work a diferent way and it won't Lets says I change 18.0 to (setq val 18.0) (setq ent (entget (entlast))) ent (subst '(43 . val) (assoc 43 ent) ent) ) (entmod ent) it returns this : ; error: bad DXF group: (43 . VAL) Seems to me I can't But I figured out what to do while wrtting this message (setq val 18) (setq ent (entget (entlast)) ent (subst (cons (car(assoc 43 ent)) val) (assoc 43 ent) ent) ) Thanks again anyways Your great wisdoms is always in the right spot Quote
Lee Mac Posted October 18, 2012 Posted October 18, 2012 Lets says I change 18.0 to (setq val 18.0) (setq ent (entget (entlast))) ent (subst '(43 . val) (assoc 43 ent) ent) ) (entmod ent) it returns this : ; error: bad DXF group: (43 . VAL) Seems to me I can't The reason that your modification fails is because an expression preceded by an apostrophe is not evaluated, but rather taken as a 'literal' expression (i.e. taken at 'face-value'). Hence, the variable val is not evaluated, but interpreted simply as a symbol (VAL) (setq val 18) (setq ent (entget (entlast)) ent (subst (cons (car(assoc 43 ent)) val) (assoc 43 ent) ent) ) Please note: (car (assoc 43 ent)) = 43 Hence the code could become: (setq val 18.0 ent (entget (entlast)) ent (subst (cons 43 val) (assoc 43 ent) ent) ) (entmod ent) Thanks again anyways Your great wisdoms is always in the right spot You're very welcome, and thank you for your kind compliments. Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 Well I have a new question ! ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ CE PROGRAM EST CONÇU POUR COFFRER ¦¦¦; ;¦¦¦ UNE DALLE DE BÉTON ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ AUTEUR : CadFrank, Copyright ® 2012 ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program défini les calques ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun NouveauCalque(/ lay) (foreach lay '("-LU SYMBOLE") (if (not (tblsearch "LAYER" lay)) (progn (command "_layer" "_n" "-LU SYMBOLE" "_C" "90" "-LU SYMBOLE" "" "") ) );if );foreach ); fin NouveauCalque ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program défini les ¦¦¦; ;¦¦¦ parametres initial ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun Parametreinitial () (setq retour (list (cons "osmode" (getvar 'osmode)) (cons "clayer" (getvar 'clayer)) ) ) (setvar 'OSMODE 0) retour ; la dernière expression est retournée par la fonction ); fin parametreinitial ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program remet les ¦¦¦; ;¦¦¦ parametres initial ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun Parametrefin (retour) (foreach p retour (setvar (car p) (cdr p)) ) );fin parametrefin ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program divide ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun div (x y / *error*) (defun *error* (msg) (princ (strcat "\nErreur dans la fonction div: " msg)) (princ) ) (/ x (float y)) ) ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ PROGRAM PRINCIPAL ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun c:BCA (/ Entt pt1 pt2 dist1 dist2 ech1 rec1 rec2) (NouveauCalque) (setq init (Parametreinitial)) (initget 1) (setq Entt (Entget(car(Entsel)))) (setq pt1 (cdr (assoc '10 Entt))) (setq dist1 (cdr (assoc '42 Entt))) (setq dist2 (cdr (assoc '43 Entt))) (setq ech1 (* (float(cdr (assoc '40 Entt))) (div 2 3))) (setq ech2 (div (float(cdr (assoc '40 Entt))) 2)) (setq pt2 (list (+ (car pt1) dist1) (- (cadr pt1) dist2))) (setvar "clayer" "-LU SYMBOLE") (command "_rectangle" pt1 pt2) (setq rec1 (entlast)) (command "_offset" ech1 rec1 (polar pt1 180 1) "") (command "_erase" rec1 "") (setq rec2 (entlast)) (command "_offset" ech1 rec2 (reverse (polar pt1 180 1)) "") (setq rec3 (entlast)) (setq rec2 (entget rec2) rec2 (subst (cons 43 ech2) (assoc 43 rec2) rec2) ) (entmod rec2) (setq rec3 (entget rec3) rec3 (subst '(62 . 61) (assoc 62 rec3) rec3) ) (entmod rec3) (parametrefin init) (princ) ) now I'm trying to change the color of my rec3 but i've noticed I don't see the dxf code 62 in the entity so I can't really change it. Do I have to use chprop or I can use subst? Quote
Tharwat Posted October 18, 2012 Posted October 18, 2012 If the object 's color is ByLayer , the DXF code 62 would be nil , so consider this way which is better than the use of command call . e.g. (setq e (car (entsel))) (entmod (append (entget e) '((62 . 1)))) Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 If the object 's color is ByLayer , the DXF code 62 would be nil , so consider this way which is better than the use of command call . e.g. (setq e (car (entsel))) (entmod (append (entget e) '((62 . 1)))) Thank alot! works like a charm. But now I Have a new question I want to get all the 2d points of my rectangle (rec3) Select object: ((-1 . <Entity name: 7fffed72200>) (0 . "LWPOLYLINE") (330 . <Entity name: 7fffed379f0>) (5 . "288") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "-LU SYMBOLE") (62 . 61) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1730.51 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1730.51 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)) but all my points are on DFX 10. How can I get them seperaly ? Quote
Tharwat Posted October 18, 2012 Posted October 18, 2012 Thank alot! works like a charm. But now I Have a new question I want to get all the 2d points of my rectangle (rec3) but all my points are on DFX 10. How can I get them seperaly ? Some foods for thoughts . One way ... (if (and (setq s (car (entsel "\n Select Lwpolyline :"))) (member (cdr (assoc 0 (entget s))) '("LWPOLYLINE" "POLYLINE") ) ) (foreach dxf (entget s) (if (eq (car dxf) 10) (setq pts (cons dxf pts)) ) ) ) Quote
Lee Mac Posted October 18, 2012 Posted October 18, 2012 I want to get all the 2d points of my rectangle (rec3) but all my points are on DFX 10. How can I get them seperaly? http://www.cadtutor.net/forum/showthread.php?73360-polyline-manipulation&p=500564&viewfull=1#post500564 Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 Some foods for thoughts . One way ... Well I made it work with my code and now it gives me an error ; error: bad argument type: lentityp ((-1 . <Entity name: 7fffed72540>) (0 . "LWPOLYLINE") (330 . <Entity name: 7fffed379f0>) (5 . "2BC") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "-LU SYMBOLE") (62 . 61) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1730.51 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1790.41) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2769.28 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1730.51 1260.14) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)) But I can't seem to pin point where it's from. Can I get a little more help so i can understand the error pretty plz Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 http://www.cadtutor.net/forum/showthread.php?73360-polyline-manipulation&p=500564&viewfull=1#post500564 not sure how I can use those hehe !! But thanks again Lee ill take some time to analyse them Cheerws and Beers ! Quote
Tharwat Posted October 18, 2012 Posted October 18, 2012 Well I made it work with my code and now it gives me an error But I can't seem to pin point where it's from. Can I get a little more help so i can understand the error pretty plz Just post the code that you used and got that error . You may have used entget function on selection set and not on ssname Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 Yeah I forgot to post the code.. hehe silly me. I kinda figured it out I was using Enget twice Like this (setq rec3 (entlast)) (if (and (setq ent1 (entget rec3) (member (cdr (assoc 0 (entget ent1))) '("LWPOLYLINE" "POLYLINE") ) ) (foreach dxf (entget ent1) (if (eq (car dxf) 10) (setq pts (cons dxf pts)) ) ) ) (setq p1 (cdr(car pts))) (setq p2 (cdr(cadr pts))) (setq p3 (cdr(caddr pts))) (setq p4 (cdr(caddr(cdr pts)))) Now I have another puzzle ! I'm creating lines from those point any way to do it without "command" I tried with Entmake and its kinda hard lol! Quote
Tharwat Posted October 18, 2012 Posted October 18, 2012 Since that you known that you have used the entget function twice , why did not you correct it ? It is good for all to explain what you are trying to accomplish one time . Quote
CadFrank Posted October 18, 2012 Author Posted October 18, 2012 (edited) Oh well I did correct it ! I just wanted to show you my mistake. but here's my code : ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ CE PROGRAM EST CONÇU POUR DESSINER ¦¦¦; ;¦¦¦ UNE BOITE AUTOUR D'UN MTEXT ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ AUTEUR : CadFrank, Copyright ® 2012 ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program défini les calques ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun NouveauCalque(/ lay) (foreach lay '("-LU SYMBOLE") (if (not (tblsearch "LAYER" lay)) (progn (command "_layer" "_n" "-LU SYMBOLE" "_C" "90" "-LU SYMBOLE" "" "") ) );if );foreach ); fin NouveauCalque ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program défini les ¦¦¦; ;¦¦¦ parametres initial ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun Parametreinitial () (setq retour (list (cons "osmode" (getvar 'osmode)) (cons "clayer" (getvar 'clayer)) ) ) (setvar 'OSMODE 0) retour ; la dernière expression est retournée par la fonction ); fin parametreinitial ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program remet les ¦¦¦; ;¦¦¦ parametres initial ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun Parametrefin (retour) (foreach p retour (setvar (car p) (cdr p)) ) );fin parametrefin ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program divide ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun div (x y / *error*) (defun *error* (msg) (princ (strcat "\nErreur dans la fonction div: " msg)) (princ) ) (/ x (float y)) ) ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program converti ¦¦¦; ;¦¦¦ des degrés en radians ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun dtr (a) (* pi (/ a 180.0)) ) ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ PROGRAM PRINCIPAL ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun c:BCA (/ Entt pt1 pt2 dist1 dist2 ech1 ech2 rec1 rec2 rec3 p1 p2 p3 p4 pts dxf ent1) (NouveauCalque) (setq init (Parametreinitial)) (if (and (not (while (progn (setvar 'errno 0) (setq Entt (car (entsel "\n Sélectionner le MultiText désiré : ")) ) (cond ((= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ((eq 'ename (type Entt)) (if (not (eq (cdr (assoc 0 (entget Entt))) "MTEXT")) (princ "\nInvalid Object Selected.") ) ) ) ) ) ) Entt) (progn (setq Entt (Entget Entt)) (setq pt1 (cdr (assoc 10 Entt))) (setq dist1 (cdr (assoc 42 Entt))) (setq dist2 (cdr (assoc 43 Entt))) (setq ech (float(cdr (assoc 40 Entt)))) (setq ech1 (* (float(cdr (assoc 40 Entt))) (div 2 3))) (setq ech2 (div (float(cdr (assoc 40 Entt))) 2)) (setq pt2 (list (+ (car pt1) dist1) (- (cadr pt1) dist2))) (setvar "clayer" "-LU SYMBOLE") (command "_rectangle" pt1 pt2) (setq rec1 (entlast)) (command "_offset" ech1 rec1 (polar pt1 180 1) "") (command "_erase" rec1 "") (setq rec2 (entlast)) (command "_offset" ech1 rec2 (reverse (polar pt1 -90 1)) "") (setq rec2 (entget rec2) rec2 (subst (cons 43 ech2) (assoc 43 rec2) rec2) ) (entmod rec2) (setq rec3 (entlast)) (entmod (append (entget rec3) '((62 . 61)))) (if (and (setq ent1 rec3) (member (cdr (assoc 0 (entget ent1))) '("LWPOLYLINE" "POLYLINE") ) ) (foreach dxf (entget ent1) (if (eq (car dxf) 10) (setq pts (cons dxf pts)) ) ) ) (setq p1 (car pts)) (setq p2 (cadr pts)) (setq p3 (caddr pts)) (setq p4 (caddr(cdr pts))) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p1) (caddr p1))) (cons 11 (list (- (cadr p1) ech) (caddr p1))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p1) (caddr p1))) (cons 11 (list (cadr p1) (- (caddr p1) ech))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p2) (caddr p2))) (cons 11 (list (+ (cadr p2) ech) (caddr p2))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p2) (caddr p2))) (cons 11 (list (cadr p2) (- (caddr p2) ech))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p3) (caddr p3))) (cons 11 (list (+ (cadr p3) ech) (caddr p3))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p3) (caddr p3))) (cons 11 (list (cadr p3) (+ (caddr p3) ech))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p4) (caddr p4))) (cons 11 (list (- (cadr p4) ech) (caddr p4))) ) ) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 (list (cadr p4) (caddr p4))) (cons 11 (list (cadr p4) (+ (caddr p4) ech))) ) ) (parametrefin init) ) (princ "\nMtext selected: ")) (princ) ) So I'm down to that! but the use of it is by selecting a Mtext it does a box around it And I'm trying to make it look fancy ! Edited October 22, 2012 by CadFrank Quote
Tharwat Posted October 19, 2012 Posted October 19, 2012 I'm creating lines from those point any way to do it without "command" I tried with Entmake and its kinda hard lol! lst = list of points e.g ((10 18.3641 5.87388) (10 18.3641 12.9845) (10 15.022 12.9845) (10 15.022 5.87388)) (setq i 0) (repeat (length lst) (setq p1 (nth i lst)) (if (eq (setq p2 (nth (setq i (1+ i)) lst)) nil) (setq p2 (nth 0 lst)) ) (entmakex (list '(0 . "LINE") (cons 10 (list (cadr p1) (caddr p1))) (cons 11 (list (cadr p2) (caddr p2))) ) ) ) Quote
CadFrank Posted October 19, 2012 Author Posted October 19, 2012 Well thanks again I'll poste them code when I'm done. Cheers Quote
Tharwat Posted October 19, 2012 Posted October 19, 2012 Well thanks again I'll poste them code when I'm done. Cheers okay , I am waiting for a succeed full routine . Quote
Tharwat Posted October 22, 2012 Posted October 22, 2012 In your sub-function for creating the layer , there is no need for foreach and progn functions at all beside that you have extra quotes in the layer command call => "" which should be removed . and for the entmakex function , you can reduce all these repeated lines on entmake with one sub-function like this . (defun DrawLine (point1 point2) (entmakex (list '(0 . "LINE") (cons 8 "-LU SYMBOLE") (cons 62 61) (cons 10 point1) (cons 11 point2) ) ) ) usage of above sub-function . (DrawLine (list (cadr p1) (caddr p1)) (list (- (cadr p1) ech) (caddr p1))) Consider the angle of the Mtext string . Best of luck Tharwat Quote
Tharwat Posted October 23, 2012 Posted October 23, 2012 Try this Frank on all kind of rotated Mtexts . (defun c:MtextFrame (/ *error* _Line ang e h ht i p p1 p2 p3 p4 p5 p6 p7 p8 ss v) (vl-load-com) ;;; Author : Tharwat Al Shoufi 23. Oct. 2012 ;;; (if (not acdoc) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (defun *error* (x) (vla-EndUndoMark acdoc) (setvar 'cmdecho 1) (princ "\n ...") (princ "\n *Cancel*") ) (if (not (tblsearch "LAYER" "-LU SYMBOLE")) (vl-cmdf "._-layer" "_n" "-LU SYMBOLE" "_C" "90" "-LU SYMBOLE" "") ) (defun _Line (pt1 pt2) (entmakex (list '(0 . "LINE") '(8 . "-LU SYMBOLE") '(62 . 61) (cons 10 pt1) (cons 11 pt2))) ) (if (setq ss (ssget '((0 . "MTEXT") (71 . 1) (72 . 5)))) (progn (vla-StartUndoMark acdoc) (setvar 'cmdecho 0) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (mapcar 'set '(p h v ang ht) (list (cdr (assoc 10 e)) (cdr (assoc 42 e)) (cdr (assoc 43 e)) (cdr (assoc 50 e)) (cdr (assoc 40 e)) ) ) (setq p1 (polar (polar p (+ ang pi) (* ht 0.65)) (+ ang (/ pi 2.)) (* ht 0.65)) p3 (polar (setq p2 (polar p1 ang (+ (* (* ht 0.65) 2.) h))) (+ ang (* pi 1.5)) (+ (* (* ht 0.65) 2.) v) ) p4 (polar p3 (+ ang pi) (+ (* (* ht 0.65) 2.) h)) p5 (polar (polar p1 (+ ang pi) (* ht 0.65)) (+ ang (/ pi 2.)) (* ht 0.65)) p6 (polar p5 ang (+ (* (* ht 0.65) 4.) h)) p7 (polar p6 (+ ang (* pi 1.5)) (+ (* (* ht 0.65) 4.) v)) p8 (polar p7 (+ ang pi) (+ (* (* ht 0.65) 4.) h)) ) (mapcar '_Line (list p5 p5 p6 p6 p7 p7 p8 p8) (list (polar p5 (+ ang (/ pi 2.)) ht) (polar p5 (+ ang pi) ht) (polar p6 (+ ang (/ pi 2.)) ht) (polar p6 ang ht) (polar p7 ang ht) (polar p7 (+ ang (* pi 1.5)) ht) (polar p8 (+ ang pi) ht) (polar p8 (+ ang (* pi 1.5)) ht) ) ) (vl-cmdf "_.Pline" "_non" p1 "_non" p2 "_non" p3 "_non" p4 "c") (vla-put-constantwidth (vlax-ename->vla-object (entlast)) (/ ht 3.)) (vl-cmdf "_.Pline" "_non" p5 "_non" p6 "_non" p7 "_non" p8 "c") (vla-put-constantwidth (vlax-ename->vla-object (entlast)) 0.0) ) (vla-EndUndoMark acdoc) (setvar 'cmdecho 1) ) ) (princ "\n Written by Tharwat Al Shoufi") (princ) ) Quote
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.