TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pabac68010 on August 30, 2021, 02:36:27 PM
-
I'm looking for a Lisp to place a specific block in a center of an Area. For example: in a Hall I'd like to place a smoke detector automatically at the center of the hall.
Any Help is really appreciated. TIA.
-
Look into the 'geometric center' osnap.
Welcome to TheSwamp :)
-
Geo center only works with closed polylines. It might be better to use snap to midpoint of 2 points.
If you hold shift + right click when picking the insertion point of the block it will pop up a menu with all the snaps.
-
Shift + Right click mouse for options.
This takes advantage of transparent commands. I would have it as part of a library auto loaded lisp on start up.
(defun c:aaa ()(osnap (vlax-curve-getStartPoint (car (entsel))) "gcen"))
eg 1 LINE 'aaa pick closed pline
eg2 -insert blkname 'aaa pick closed pline
-
Lisp I've used for years added macro to Object Snap Cursor Menu:
; Middle Object Osnap
; Macro: ^P(or midobj (load "midobj.lsp")(princ))(midobj)
(defun midobj (/ ll ur selection pntlist pnts adoc)
(setq selection (car (entsel))
adoc (vla-get-activedocument (vlax-get-acad-object))
)
(vla-getboundingbox (vlax-ename->vla-object selection) 'll 'ur)
(setq pntlist (mapcar 'vlax-safearray->list (list ll ur)))
(list(/(+(caar pntlist)(caadr pntlist))2.0)(/(+(cadar pntlist)(cadadr pntlist))2.0))
)
-
I'm Kind of new to Autocad so I'm not aware of programming. I saw a video on youtube and that dude using some plugins to create this but I hope there might be some LISP Programs for the same. Ill share the Youtube Link Below. PLEASE IGNORE THE AUDIO.
https://www.youtube.com/watch?v=Ew2uDVWJMYo
-
We did provide answers, what is missing is place in centre of room, how is the room defined is it a closed area, a hatch pattern, or has openings, in which case just use M2P a built find command middle of 2 points. To many unknowns.
insert bname M2P ......