rwsice9 Posted March 29, 2011 Share Posted March 29, 2011 I have a LISP file that inserts a block. While inserting the block the user must pick the insertion point, and a rotation point, which gets stored as a local variable so that another block can be inserted in exactly the same place, at the same angle. Does anyone know if there is a way to allow the first block to be visible while inserting so the user can see the rotation angle? Also, is there a way to make the lisp follow whether Ortho is enabled? Thanks for your help! Quote Link to comment Share on other sites More sharing options...
JohnM Posted March 29, 2011 Share Posted March 29, 2011 could you post your lisp and give greater detail of what you would like to achieve Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 29, 2011 Share Posted March 29, 2011 Quickly written example code: (defun c:test ( / attreq block1 block2 elast ) (setq attreq (getvar 'ATTREQ)) (setvar 'ATTREQ 0) (if (and (setq block1 (getfiled "Select First Block" "" "dwg" 16)) (setq block2 (getfiled "Select Second Block" "" "dwg" 16)) ) (progn (setq elast (entlast)) (command "_.-insert" block1 pause 1. 1. pause) (if (not (equal elast (setq elast (entlast)))) (command "_.-insert" block2 "_non" (cdr (assoc 10 (entget elast))) 1. 1. (* 180. (/ (cdr (assoc 50 (entget elast))) pi)) ) ) ) ) (setvar 'ATTREQ attreq) (princ) ) Quote Link to comment Share on other sites More sharing options...
rwsice9 Posted March 30, 2011 Author Share Posted March 30, 2011 Basically here's what I want to happen. We design fire alarm systems, and we insert blocks aligned with walls. The way they worked in the past was just a simple macro, but I wanted to write a lisp to automatically insert a block showing the coverage area of the strobe lights. The reason I had to write a lisp is, the strobe block gets inserted at different scales, but the coverage block must always be inserted at 1:1. Here is the lisp I am using now, which works perfectly, but my coworkers are asking if there is a way to have the strobe block visible while the lisp is running so they can see the rotation of the block as it happens. (defun RTD (x) ;define degrees to radians function (* 180 (/ x pi)) ;divide the angle by 180 then ;multiply the result by the constant PI ) ;end of function (defun c:S15CD();strobe wall 15 (setq CVR (getvar "useri2") SCL (GETVAR "userr1") lyr (getvar "clayer") osm (getvar "osmode") ) (if (= 0 scl)(command (alert "Please Set your scale and try agagin")(exit))) (COMMAND "OSMODE" "514") (setq PT1 (getpoint "\nSelect Insertion Point") PT2 (getpoint "\nSelect Rotation Angle") RT (rtd (angle PT1 PT2)) );setq (COMMAND "-LAYER" "s" "F-ALRM-INDC" "") (COMMAND "-INSERT" "STROBE_ONLYW15" PT1 SCL "" rt) (if (= 1 cvr)(command "-layer" "s" "F-STRB-COVR" "")) (IF (= 1 CVR)(command "-insert" "sg-15cd" PT1 "1" "" rt)) (COMMAND "CLAYER" LYR) (COMMAND "OSMODE" OSM) ;(command "script" "torient") );strobe wall 15 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2011 Share Posted March 30, 2011 Study my example for the answer :wink: Quote Link to comment Share on other sites More sharing options...
rwsice9 Posted March 30, 2011 Author Share Posted March 30, 2011 I'm pretty new to the LISP writing.. but I think i might see what your code is doing..maybe.. Looks like you have it inserting block1, then selecting it with entlast, getting the rotation angle, then inserting block2 with matching properties? I think my issue is.. I can kinda read your code and understand what its doing, but still cant quite figure how to make it work correctly with my code without breaking it.. Quote Link to comment Share on other sites More sharing options...
alanjt Posted March 30, 2011 Share Posted March 30, 2011 A little helpful nudge... You are prompting the user for a rotation angle (rt variable), remove that prompt and replace rt with PAUSE in the command for insert. Quote Link to comment Share on other sites More sharing options...
SOliver Posted March 30, 2011 Share Posted March 30, 2011 For my pennies worth: Once you've picked a point for the insertion you could pick the wall which you want to align it to. Determine the side of the insertion point using (setq entSelectionPoint(cdar ent)) followed by using the same value to determine which line in the polyline that you clicked on to determine the angle. Only thing there is you might want to determine a specific offset from the line in which case the the selected point would just be used for determining the side of the wall which the block will reside. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted March 30, 2011 Share Posted March 30, 2011 If you want a fairly robust INSERT, then I'd go with something like this: (defun nw_sert (b / in_var) (command "_.UCS" "_World") (SetLayer "0") (setq in_var '( ("CMDECHO" . 0) ("BLIPMODE" . 1) ("EXPERT" . 0) ("SNAPMODE" . 1) ("ORTHOMODE" . 1) ("GRIDMODE" . 0) ("ELEVATION" . 0) ("THICKNESS" . 0) ("FILEDIA" . 0) ("FILLMODE" . 0) ("SPLFRAME" . 0) ("TEXTEVAL" . 0) ("ATTDIA" . 0) ("ATTREQ" . 0) ("ATTMODE" . 2) ("UCSICON" . 1) ("HIGHLIGHT" . 1) ("COORDS" . 2) ("DRAGMODE" . 2) ("CECOLOR" . "BYLAYER") ("CELTYPE" . "BYLAYER"))) (foreach v in_var (setvar (car v) (cdr v))) (princ "\nInsert Point: ") (command "_.INSERT" b pause 1 1) (princ "\nInsert Angle <0>: ") (command pause) (while (> (getvar "CMDACTIVE") 0) (command "")) (prin1)) -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2011 Share Posted March 30, 2011 Why the need to change all those System Variables David? Also, you don't reset them... Quote Link to comment Share on other sites More sharing options...
rwsice9 Posted March 30, 2011 Author Share Posted March 30, 2011 So.. if i use the pause, would i change the code to something like this? (COMMAND "-INSERT" "STROBE_ONLYW15" pause (setq pt1(getpoint "\nSelect Insertion Point") SCL "" pause (setq pt2(getpoint "\nPick Angle")) then take the values for PT1 and PT2, compute the angle and insert the other block? Or am i totally wrong? Quote Link to comment Share on other sites More sharing options...
alanjt Posted March 30, 2011 Share Posted March 30, 2011 So.. if i use the pause, would i change the code to something like this? (COMMAND "-INSERT" "STROBE_ONLYW15" pause (setq pt1(getpoint "\nSelect Insertion Point") SCL "" pause (setq pt2(getpoint "\nPick Angle")) then take the values for PT1 and PT2, compute the angle and insert the other block? Or am i totally wrong? No. Just take the angle and (optional) insertion point from the first inserted block and apply it to the second. Look at Lee's example (assoc 50 will give you the rotation and (assoc 10 will give you the insertion point. Quote Link to comment Share on other sites More sharing options...
rwsice9 Posted March 30, 2011 Author Share Posted March 30, 2011 Awesome.. See thats the kind of stuff Im still learning.. the assoc 10, assoc 50. I had no idea what those were! Thanks for your help everyone! Quote Link to comment Share on other sites More sharing options...
alanjt Posted March 30, 2011 Share Posted March 30, 2011 Awesome.. See thats the kind of stuff Im still learning.. the assoc 10, assoc 50. I had no idea what those were! Thanks for your help everyone! (mapcar 'print (entget (car (entsel)))) click on an object and you'll see everything that's available. http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WSfacf1429558a55de185c428100849a0ab7-5f35.htm http://images.autodesk.com/adsk/files/acad_dxf2.pdf Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 31, 2011 Share Posted March 31, 2011 This will help you in that respect also http://lee-mac.com/entitylist.html Quote Link to comment Share on other sites More sharing options...
rwsice9 Posted April 7, 2011 Author Share Posted April 7, 2011 Got the LISP working how I wanted it to. Thanks guys! Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 7, 2011 Share Posted April 7, 2011 Right on. ..... 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.