Point1 and Point2 to Hatch

Point1 and Point2 to Hatch

k005
Advisor Advisor
1,944 Views
28 Replies
Message 1 of 29

Point1 and Point2 to Hatch

k005
Advisor
Advisor

Hello everyone


As I mentioned in the attachment, how can I have a solid scan automatically when I mark pt1 and pt2?


The place where I operate is a closed area...


Thanks.

 

 

SOLIDHATCH.jpg

0 Likes
1,945 Views
28 Replies
Replies (28)
Message 2 of 29

Sea-Haven
Mentor
Mentor

-Hatch mp etc the point is the midpoint of pt1 pt2.

(setq mp (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5)))

 

0 Likes
Message 3 of 29

k005
Advisor
Advisor

well okay. But how should the rest of the code be?

0 Likes
Message 4 of 29

Sea-Haven
Mentor
Mentor

Don't you know how to do getpoint and -hatch ?

 

You have asked for lots of stuff should be learning by now.

0 Likes
Message 5 of 29

calderg1000
Mentor
Mentor
Accepted solution

Regards @k005 

Here you have two options to select the interior point, requested by the Hatch command. Although I think there must be a simpler way to do it.

;;;___
(defun c:hh1 (/ p1 p2 pm)
  (setq p1 (getpoint "\nPick Point 1: ")
        p2 (getpoint p1 "\nPick Point 2: ")
        pm (mapcar '(lambda (x y) (/ (+ x y) 2.)) p1 p2)
  )
  (command "_-hatch" "p" "s" pm "")
)

;;;___
(defun c:hh2 (/ p1 p2 pm)
  (setq p1 (getpoint "\nPick Point 1: ")
        p2 (getpoint p1 "\nPick Point 2: ")
  )
  (command "_line" "_non" p1 "_non" p2 "")
  (setq pm
         (vlax-curve-getpointatparam (vlax-ename->vla-object (entlast)) 0.5)
  )
  (entdel (entlast))
  (command "_-hatch" "p" "s" pm "")
)


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 6 of 29

k005
Advisor
Advisor

Hi @calderg1000 

 

I tried hh1 and it worked. hh2 did not work. There is only one problem. I show it in the attachment. It doesn't scan the whole thing... just the middle part.


It needs to scan all of them.

 

 

solid1.jpg

 

 

 

0 Likes
Message 7 of 29

ronjonp
Mentor
Mentor

@k005 

Why would you want to pick two points when natively you can pick one to hatch?

ronjonp_0-1694527950795.png

 

0 Likes
Message 8 of 29

k005
Advisor
Advisor

Because this isn't just a scan... this is the completion of a function. additional code.

 

It will be added to the function here...

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wall-calculate/td-p/10499229

0 Likes
Message 9 of 29

CADaSchtroumpf
Advisor
Advisor
Accepted solution

For basic use you could use this.
This does not create hatching, but a solid which will turn out to be less demanding in definition.

(defun c:foo ( / p1 p2 p3 p4)
  (initget 9)
  (setq p1 (trans (getpoint "\nFirstpoint: ") 1 0))
  (initget 41)
  (setq
    p4 (trans (getcorner (trans p1 0 1) "\Second point: ") 1 0)
    p2 (list (car p1) (cadr p4))
    p3 (list (car p4) (cadr p1))
  )
  (entmake
    (append
      (list
        '(0 . "SOLID")
        '(100 . "AcDbEntity")
        (cons 410 (getvar "CTAB"))
        (cons 8 (getvar "CLAYER"))
        '(100 . "AcDbTrace")
        (cons 10 p1)
        (cons 11 p2)
        (cons 12 p3)
        (cons 13 p4)
        (cons 39 (getvar "ELEVATION"))
      )
    )
  )
  (prin1)
)
Message 10 of 29

k005
Advisor
Advisor

Yes . this worked. Thank you. However, I cannot integrate this code into my Wall account. It seems a bit complicated to me.

 

My goal was to add this to the function here.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wall-calculate/td-p/10499229

 

That is, scanning after pt1 and pt2 and printing the m² information. Currently only m² information is written... I should add scanning to it. and text should appear...

0 Likes
Message 11 of 29

CADaSchtroumpf
Advisor
Advisor

@k005  a écrit :

Yes . this worked. Thank you. However, I cannot integrate this code into my Wall account. It seems a bit complicated to me.

 

My goal was to add this to the function here.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wall-calculate/td-p/10499229

 

That is, scanning after pt1 and pt2 and printing the m² information. Currently only m² information is written... I should add scanning to it. and text should appear...


This?

 

(defun c:foo ( / p1 p2 p3 p4 ang wh l luk text)
  (initget 9)
  (setq p1 (trans (getpoint "\nFirst point: ") 1 0))
  (initget 41)
  (setq
    p4 (trans (getcorner (trans p1 0 1) "\nSecond point: ") 1 0)
    p2 (list (car p1) (cadr p4))
    p3 (list (car p4) (cadr p1))
  )
  (if (> (distance p1 p3) (distance p1 p2))
    (setq ang 0.0)
    (setq ang (* 0.5 pi))
  )
  (initget 7)
  (setq
    wh (getreal "\nWall height >")
    l (distance p1 p4)
    luk (min (distance p1 p3) (distance p1 p2))
    text (strcat (rtos luk 2 0) " luk Duvar : " (rtos (* l wh 1E-04) 2 2)  " m\U+00B2")
  )
  (entmake
    (list
      '(0 . "SOLID")
      '(100 . "AcDbEntity")
      (cons 410 (getvar "CTAB"))
      (cons 8 (getvar "CLAYER"))
      '(100 . "AcDbTrace")
      (cons 10 p1)
      (cons 11 p2)
      (cons 12 p3)
      (cons 13 p4)
      (cons 39 (getvar "ELEVATION"))
    )
  )
  (entmake
    (list
      '(0 . "TEXT")
      '(100 . "AcDbEntity")
      (cons 410 (getvar "CTAB"))
      (cons 8 (getvar "CLAYER"))
      '(100 . "AcDbText")
      '(62 . 250)
      '(10 0.0 0.0 0.0)
      (cons 40 luk)
      (cons 1 text)
      (cons 50 ang)
      '(71 . 0)
      '(72 . 1)
      (cons
        11
        (list
          (* (+ (car p1) (car p4)) 0.5)
          (* (+ (cadr p1) (cadr p4)) 0.5)
          (* (+ (caddr p1) (caddr p4)) 0.5)
        )
      )
      '(73 . 2)
    )
  )
  (prin1)
)

 

Message 12 of 29

k005
Advisor
Advisor

Thank you very much. , thank you for your efforts. @CADaSchtroumpf 


Can we add these parts as well?


It will be more useful if it loops and remembers the wall height.

0 Likes
Message 13 of 29

ВeekeeCZ
Consultant
Consultant

Draw a rectangle, hatch it, and remove the rectangle. Or keep it if you don't mind it.

It's just a simple macro... how difficult to write it it could be... gees.

 

(defun c:RecHatch (/ e)
  (command "_.rectang" pause pause)
  (setq e (entlast))
  (command "_bhatch" "_s" e "" ""
	   "_.erase" e "")
  (princ)
  )
0 Likes
Message 14 of 29

k005
Advisor
Advisor

Why should I draw rectangle? Is there such a thing as drawing a rectangle for the purpose? Have you seen something like this?

0 Likes
Message 15 of 29

ВeekeeCZ
Consultant
Consultant

You are looking for the simplest and reasonably efficient way to automate a task. And if this means simply drawing a helper object, then that's a legitimate way to solve the issue.

0 Likes
Message 16 of 29

Kent1Cooper
Consultant
Consultant
Accepted solution

If these are always and only orthogonally-oriented rectangular areas, I would suggest using the draW boundary option in the -HATCH command.  It can pull the coordinates from the two points to define corners, and there will be no object drawn that needs to be deleted.  In simplest terms, and lightly tested:

 

(defun C:HRS (/ p1 p2); = Hatch Rectangle Solid
  (setq
    p1 (getpoint "\nCorner of Hatched rectangle: ")
    p2 (getcorner p1 "\nOpposite corner: ")
  ); setq
  (command "_.-hatch" "_properties" "_solid" "_W" "_no"
    "_non" (list (car p1) (cadr p1)) "_non" (list (car p2) (cadr p1))
    "_non" (list (car p2) (cadr p2)) "_non" (list (car p1) (cadr p2))
    "_close" "" ""
  ); command
  (prin1)
)

 

 

Kent Cooper, AIA
Message 17 of 29

k005
Advisor
Advisor

I'll look into this... Thank you.

0 Likes
Message 18 of 29

pendean
Community Legend
Community Legend

@k005 wrote:

Why should I draw rectangle? Is there such a thing as drawing a rectangle for the purpose? Have you seen something like this?


HATCHes are rectangular, you always have to account for the other two corners in your PT1-PT2 lisp-wish: this is just a different way to do that.

0 Likes
Message 19 of 29

k005
Advisor
Advisor

Awesome .! Thank you for your hard work.


I added this to the code below. it was very nice.

 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/wall-calculate/td-p/10499229

 

 

We, technical people, should work with 0 errors or very close to 0 errors... 😉

 

0 Likes
Message 20 of 29

CADaSchtroumpf
Advisor
Advisor

@k005  a écrit :

Thank you very much. , thank you for your efforts. @CADaSchtroumpf 


Can we add these parts as well?


It will be more useful if it loops and remembers the wall height.


Certainly we could improve the code to memorize the last value of the wall height.
But one feature of autocad, which works for both user input for native commands and for input in lisp codes is that: when prompted to enter a value, you press the up arrow on the keyboard of the directional pad.
This action recalls the last value entered, you only have to validate by entry to validate this value.
It is a sort of history of previously entered values.

0 Likes