Steven P Posted September 28, 2018 Posted September 28, 2018 Good morning, Just a quick one, I have a load of rectangular shaped hatched areas and need to find the coordinates of their centre - is there a LISPout there that will do that? I have seen some that give me the corners, but I am wanting the centre. (I know I could work it out from the corners but unfortunately time isn't on my side to do all that as a LISP today.) Thanks Quote
SLW210 Posted September 28, 2018 Posted September 28, 2018 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please post in the appropriate forum. Quote
Steven P Posted September 28, 2018 Author Posted September 28, 2018 46 minutes ago, SLW210 said: I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. Please post in the appropriate forum. Thanks Quote
rkmcswain Posted September 28, 2018 Posted September 28, 2018 So you have multiple hatch objects, and you want the center of them all. What do you want to do with this info once you've found it? Place an entity at these points? List them in a table? Export these values to an ASCII file? Something else? Quote
JuniorNogueira Posted September 28, 2018 Posted September 28, 2018 (edited) Something like ? Not tested. (defun c:CtrCoo (/ findctr a apt) (defun findctr (en / pt) (command "_.Zoom" "_Object" en "") (setq pt (getvar 'viewctr)) (command "_.Zoom" "_Previous") pt ) (setq a (car (entsel "Select Rectangle: : ")) apt (findctr a)) (command "_Text" "_Justify" "_MC" apt 0.1 0 apt) (princ) ) Edited September 28, 2018 by JuniorNogueira Quote
rkmcswain Posted September 28, 2018 Posted September 28, 2018 This places a red circle at the center of multiple hatch objects. Only tested on a basic WCS drawing with rectangular hatch objects. You should be able to take this and modify it to your needs. (defun c:foo ( / sset ent obj minPt maxPt p1 p2 midPt) (setq sset (ssget '((0 . "HATCH"))) i 0) (repeat (sslength sset) (setq ent (ssname sset i)) (setq obj (vlax-ename->vla-object ent)) (vla-getboundingbox obj 'minPt 'maxPt) (setq p1 (vlax-safeArray->list minPt)) (setq p2 (vlax-safeArray->list maxPt)) (setq midPt (mapcar '(lambda (x1 x2) (/ (+ x1 x2) 2.0)) p1 p2)) (entmakex (list (cons 0 "CIRCLE")(cons 62 1)(cons 10 midPt)(cons 40 (* (getvar "viewsize") 0.03)))) (setq i (1+ i)) ) (princ) ) Quote
Steven P Posted September 28, 2018 Author Posted September 28, 2018 thanks CtrCoo is exactly what I was looking for (the client wants a list of coordinates of pits to be dug, the pits are shown as rectangular hatched areas, ideally if I could I would have exported to a text file to populate a table with later.. but for now and for speed CtrCoo and type the numbers into the table). I like Foo - putting a circle in the centre of each hatch, I will keep that to one side for now and it might come in useful later, thanks 1 Quote
BIGAL Posted September 29, 2018 Posted September 29, 2018 (edited) If you have circles then export out centre point thats the set out pt. A simple lisp usiings ssget with circle filter. Our pits are set out as a center point or as 2 points so you get orientation correct. We would use the pit itself for setout we make 4 sided plines so centroid is middle of 1-3 or 2-4 points. In the case of a pit behind a kerb you need 2 points else the kerb will not align properly when the kerb machine goes over the top. We would create points as we go then just create a point setout file. Edited September 29, 2018 by BIGAL 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.