CadFrank Posted April 22, 2013 Posted April 22, 2013 Hi, I would like to know if their's a possibility of extracting into a variable the rotation value of a rectangle. then set it to 0 and reputting it to it originale value after. Thx Quote
Tharwat Posted April 22, 2013 Posted April 22, 2013 Hi Frank . Try to extract the coordinates and after that you may need to check if each segment 's angle is equal to 0.0 , 90.0 , 180. or 270.0 so the rectangle would be straight otherwise it is not . Quote
CadFrank Posted April 22, 2013 Author Posted April 22, 2013 Hey Tharwat, Thanks for you answer, I'm not sure to follow you on it though. lets say I use the command rectangle and use the rotate to give it an angle. now it save that angle all the time. So when I use a routine that uses rectangle command it sticks with that angle. So I know i can use the rotate to put it back to 0 in my routine but i'd rather just save that angle then set it to 0. If it's not possible I could always find another way of doing my block. Anyways hope it helps more Cheers and Beers ! Quote
BIGAL Posted April 23, 2013 Posted April 23, 2013 A bit of a lisp very simply put together pick two points of an existing object if you wnat stuff like width and height needs to be added, same with one pick existing object. (defun rec () (setq pt1 (getpoint "\npick cnr point")) (setq pt2 (getpoint "\npick next cnr point")) ) (rec) (setq ang (angle pt1 pt2)) (rec) (command "rectang" pt1 pt2) (command "ro" "L" "" pt1 ang) (princ) Quote
Lee Mac Posted April 23, 2013 Posted April 23, 2013 From what I understand, I believe CadFrank is looking to determine the current rotation angle of the rectang command so that the rotation can be reset following the use of this command; unfortunately, I don't believe this value is accessible, as it doesn't appear as a System Variable or Environment Variable. Quote
Tharwat Posted April 23, 2013 Posted April 23, 2013 Maybe this ... (defun c:Test (/ *error* rtd _P p1 p2 e pts a lst ang) ;;--- Tharwat 23. April. 2013 ---;; (defun *error* (x) (princ "\n *Cancel*")) (defun rtd (a) (/ (* a 180.0) pi)) (defun _P (ent) (mapcar 'cdr (vl-remove-if-not '(lambda (i) (eq (car i) 10)) (entget ent) ) ) ) (if (and (setq p1 (getpoint "\n Specify first corner :")) (setq p2 (getcorner "\n Specify next corner :" p1)) ) (progn (command "_.rectang" "_none" p1 "_none" p2) (setq e (entlast)) (setq pts (_P e)) (setq a (angle (car pts) (cadr pts))) (command "_.rotate" e "" (mapcar '(lambda (j k) (/ (+ j k) 2.)) (car pts) (caddr pts) ) pause ) (setq lst (_P (entlast))) (setq ang (- (angle (car lst) (cadr lst)) a)) ) ) (if ang (princ (strcat "\n The rotation angle is : " (rtos (rtd ang) 2 1)) ) ) (princ) ) (vl-load-com) Quote
Stefan BMR Posted April 23, 2013 Posted April 23, 2013 lets say I use the command rectangle and use the rotate to give it an angle. now it save that angle all the time. So when I use a routine that uses rectangle command it sticks with that angle. So I know i can use the rotate to put it back to 0 in my routine but i'd rather just save that angle then set it to 0. If it's not possible I could always find another way of doing my block. Anyways hope it helps more Cheers and Beers ! If you don't need other options available in native command, you can re-create "rectangle" command. (defun c:myrectangle ( / p1 p2 p3 p4 d) (if (and (setq p1 (getpoint "\nFirst corner: ")) (setq p2 (getpoint p1 "\nOther corner: ")) ) (progn (setq d (mapcar '- p2 p1) p3 (mapcar '+ p1 (list (car d) 0.0)) p4 (mapcar '+ p1 (list 0.0 (cadr d))) ) (command "_PLINE" "_non" p1 "_non" p3 "_non" p2 "_non" p4 "_c") ) ) (princ) ) Quote
BIGAL Posted April 24, 2013 Posted April 24, 2013 A simple way I found was if you set snapang your rectangle draws at an angle this is a variable you could retrieve and save somehow maybe userr1 then a simple macro then just do rectang. You could have up to 5 angles in dwg. (defun c:ang1 () (setvar 'angbase (getvar 'userr1)) ) ; also need (defun c:setang1 () (setvar 'userr1 (Getreal "\n enter angle")) ; i would use pick object but for example here KISS ) Quote
CadFrank Posted April 25, 2013 Author Posted April 25, 2013 Ok Well seems you all have your idea's So first of ill post the code I'm using and when the angle of the rotation is changed I get an my block doesnt work well. ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ CE PROGRAM EST CONÇU POUR FAIRE ¦¦¦; ;¦¦¦ LA COUPE DE BOIS ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ AUTEUR : CadFrank, Copyright ® 2012 ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ Ce sous-program défini les calques ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun NouveauCalque () (if (not (tblsearch "LAYER" "-LU BOIS")) (Command "_layer" "_n" "-LU BOIS" "_C" "41" "-LU BOIS" "" "") ) ); 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 crée le bloc ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun Block (pt-i di1 di2 / p2 p3 p4 p5 bent1 bent2 bent3 pti) (setq p2 (list (+ (car pt-i) di1) (+ (cadr pt-i) di2))) (setq p3 (list (car pt-i) (+ (cadr pt-i) di2))) (setq p4 (list (+ (car pt-i) di1) (cadr pt-i))) (command "_rectangle" pt-i "_d" di1 di2 pt-i) (setq bent1 (entlast)) (command "_line" pt-i p2 "") (setq bent2 (entlast)) (command "_line" p3 p4 "") (setq bent3 (entlast)) (setq pti (list (+ (car pt-i) (/ di1 2)) (+ (cadr pt-i) di2))) (command "_block" val pti bent1 bent2 bent3 "") ); fin block ;¦¦¦ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¦¦¦; ;¦¦¦ PROGRAM PRINCIPAL ¦¦¦; ;¦¦¦ _______________________________________________________________________ ¦¦¦; (defun c:bois (/ val di1 di2 pt-i) (setq init (Parametreinitial)) (NouveauCalque) (initget 1 "2x3 2x4 2x6 2x8 2x10 4x4 4x6") (setq val (getkword "\n choisir la dimension du bois [2x3/2x4/2x6/2x8/2x10/4x4/4x6] ")) (cond ((= val "2x3") (setq di1 64.0 di2 38.0 ) ) ((= val "2x4") (setq di1 90.0 di2 38.0 ) ) ((= val "2x6") (setq di1 140.0 di2 38.0 ) ) ((= val "2x8") (setq di1 190.0 di2 38.0 ) ) ((= val "2x10") (setq di1 241.0 di2 38.0 ) ) ((= val "4x4") (setq di1 90.0 di2 90.0 ) ) ((= val "4x6") (setq di1 90.0 di2 140.0 ) ) ) (setq pt-i (getpoint "\n Déterminer le point d'insertion. ")) (setvar "clayer" "-LU BOIS") (if (not (tblsearch "BLOCK" val)) (block pt-i di1 di2) ) (command "_insert" val pt-i "" "" "") (parametrefin init) (princ) );fin bois Now I know I can set my self the rotation to zero with (command "_rectangle" pt-i "_r" 0 "_d" di1 di2 pt-i) So now it permenantly set it's back to 0. And their's my problem. I don't want to set it permanently to 0, I want to extract the value to reset it to the same after using it. Now I could also modify my code so it does'nt use rectangle. So here it is.. thank for the help Cheers & Beers ! 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.