Jump to content

Visible block while LISP inserts?


rwsice9

Recommended Posts

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!

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...