Author Topic: door lisp  (Read 2190 times)

0 Members and 1 Guest are viewing this topic.

PKENEWELL

  • Bull Frog
  • Posts: 324
Re: door lisp
« Reply #15 on: December 15, 2022, 10:33:12 AM »
Thank you PKENEWELL and mhupp for the help

So did you end up with what you wanted?
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

mhupp

  • Bull Frog
  • Posts: 250
Re: door lisp
« Reply #16 on: December 15, 2022, 11:20:40 AM »
People like what they like. Can't fault anyone for that.

As for the door block It needs to been in this orientation at 0 Degrees.

and you have your Angular direction set to clockwise so its rotating the door just in the opposite  direction.
Either (setvar 'angdir 0) or update PKENEWELL's Code to the following. to work with both

Code - Auto/Visual Lisp: [Select]
  1. ; get the scale and angle
  2. (setq scl (distance p1 p2)
  3.       ang1 (angle p1 p2)
  4.       ang2 (angle p2 p1)
  5. )
  6.  
  7. ; get the scale and angle
  8. (setq scl (distance p1 p2))
  9. (if (= (getvar 'angdir 1))
  10.   (setq ang1 (- (angle p1 p2))
  11.         ang2 (- (angle p2 p1))
  12.   )
  13.   (setq ang1 (angle p1 p2)
  14.         ang2 (angle p2 p1)
  15.   )
  16. )

--edit
just fig if use mirror if block has text or door numbers it will also be mirrored.
« Last Edit: December 15, 2022, 11:25:08 AM by mhupp »

ronjonp

  • Needs a day job
  • Posts: 7535
Re: door lisp
« Reply #17 on: December 15, 2022, 11:26:49 AM »
Any reason you don't use a dynamic block for this? AutoCAD provides a sample one OOTB.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PKENEWELL

  • Bull Frog
  • Posts: 324
Re: door lisp
« Reply #18 on: December 15, 2022, 02:24:21 PM »
Any reason you don't use a dynamic block for this? AutoCAD provides a sample one OOTB.

I agree ronjonp that would be simpler. Perhaps the OP was unaware of them. Maybe however the OP has restrictions on dynamic blocks or is dictated by a customer's standards.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

PKENEWELL

  • Bull Frog
  • Posts: 324
Re: door lisp
« Reply #19 on: December 15, 2022, 02:45:07 PM »
FWIW; here is another version using both entmake and VLISP calls for the same tasks without any command calls. I prefer not hardcoding the block name and location into the main routine, but I don't know how the OP organizes the blocks. The commands call the main routine with the block desired.

Code - Auto/Visual Lisp: [Select]
  1.  
  2. ; Commands for specified blocks
  3. (defun c:ed1 nil (Insertdoorblock "c:\\blocks\\eArt67.dwg"))
  4. (defun c:ed2 nil (Insertdoorblock "c:\\blocks\\eArt68.dwg"))
  5.  
  6. ; Main routine
  7. (Defun InsertDoorBlock ( blkn / *error* adc wsp blkn os p1 p2 rs scl ang blob); localize variables
  8.    
  9.    ; Load VLISP Functions.
  10.  
  11.    ; Error handler sub-function
  12.    (defun *error* (msg)
  13.            (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*quit*,*exit*"))
  14.               (princ (strcat "\nError: " msg "\n"))
  15.          (princ "\nProgram Aborted.\n")
  16.       )
  17.       ; restore system variable to original values.
  18.      (setvar "osmode" os)
  19.      ; End undo group
  20.      (princ)
  21.    )
  22.  
  23.   ; Get old value of system variable to be changed.
  24.   (setq os (getvar "osmode")
  25.         ; Active document object
  26.         ; Layer name
  27.         lyr "WINDOOR"
  28.   )
  29.  
  30.    ; Begin undo group
  31.  
  32.   (setvar "OSMODE" 3) ; end ,mid, 1+2 =3
  33.  
  34.   (princ "\nPick 2 Points for Door Width and Location: ")
  35.   ;; ensures all input is entered before running progam to prevent errors due to operator aborting.
  36.   (if (and
  37.         (if (findfile blkn) T (progn (princ "\nBlock not found.") nil)) ; Check if Block name exists and return a warning to the command line if not, and a nil value to abort.
  38.         (setq p1 (getpoint "\nFirst (Insertion) Point: "))
  39.         (setq p2 (getpoint p1 "\nSecond Point: "))
  40.       )
  41.     (progn
  42.        ; check to see if layer exists before creating
  43.        (if (not (tblsearch "LAYER" lyr))
  44.          (entmake
  45.            (list
  46.               (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord")
  47.               (cons 100 "AcDbLayerTableRecord") (cons 2 lyr)
  48.               (cons 70 0) (cons 62 90) (cons 6 "CONTINUOUS")
  49.            )
  50.          )
  51.        )
  52.        ; get the scale and angle
  53.        (setq scl (distance p1 p2)
  54.              ang (angle    p1 p2)
  55.              wsp (vla-get-Activespace adc)
  56.        )
  57.        ; Insert the block
  58.        (setq blob (vla-InsertBlock
  59.                      (if (= wsp 1)(vla-get-Modelspace adc)(vla-get-Paperspace adc))
  60.                      (vlax-3d-point p1) blkn scl scl scl ang
  61.                   )
  62.        )
  63.        (vla-put-layer blob lyr)
  64.  
  65.        ;; Initialize Input
  66.        (initget "Yes No")
  67.        ; prompt for flip door and mirror if "Yes".
  68.        (if (= (setq rs (getkword "\nFlip Direction? [Yes/No] <No>:")) "Yes")
  69.             (progn
  70.                (vla-mirror blob (vlax-3D-Point p1) (vlax-3d-point p2))
  71.                (vla-Delete blob)
  72.             )
  73.        )
  74.     )
  75.   )
  76.  
  77.   ; restore system variable to original values.
  78.   (setvar "osmode" os)
  79.  
  80.   ; End undo group
  81.  
  82.   ; exits quietly with no return value
  83.   (princ)
  84. )
  85.  
« Last Edit: December 15, 2022, 03:14:41 PM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt