Jump to content

Centre of hatch


Steven P

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by JuniorNogueira
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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