Jump to content

Hatch to follow curved path


nod684

Recommended Posts

Hello, i am currently doing a landscaping job and i come across this problem in which the pavers (hatch pattern) should follow the curved path.

 

Is there a way to to this in lisp? I have tried using a custom linetype (with shape) but it didn't worked. I also tried the expresstools superhatch but still no avail.

 

as i was going through the threads here i still cannot find one.

But i noticed LeeMac is very good in LISP.

 

any other solution? any help would be very much appreciated

Hatch.jpg

Hatch.dwg

Edited by nod684
typo error
Link to comment
Share on other sites

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • nod684

    13

  • marko_ribar

    10

  • SEANT

    3

  • eldon

    2

Top Posters In This Topic

Posted Images

My opinion is that is possible to write such routine, but it will be an extremely complicated task. The routine will have to follow the median path and draw perpendicular on it each row of tiles – the size of tiles on each row need to be slightly adjusted (increased or decreased) from one end of the row to the other to allow the consecutive rows to fit together. Also take care to don't exceed the lateral limits. And all this for just esthetical purpose.

The said tile said size adjustment is similar with what the fitter workers will do in real life with the gap between rows.

Link to comment
Share on other sites

All I can think is something like this routine :

 

(vl-load-com)
(defun c:hatchbetween2curves ( / msp clay hpn hps ss1 ss2 c1 c2 n stpar enpar ln lnstr k par parr p1 p2 p11 p22 phor anh hdata lin ch z ssz )
 (setq msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
 (setq clay (getvar 'clayer))
 (prompt (strcat "\nType HPNAME variable <" (getvar 'hpname) "> : "))
 (setq hpn (getstring))
 (if (not (eq hpn "")) (setvar 'hpname hpn))
 (prompt (strcat "\nType HPSCALE variable <" (rtos (getvar 'hpscale)) "> : "))
 (initget 6)
 (setq hps (getreal))
 (if (not (null hps)) (setvar 'hpscale hps))
 (prompt "\nPick first curve")
 (while (not ss1)
   (setq ss1 (ssget "_+.:E:S:L" '((0 . "*LINE,RAY,XLINE,CIRCLE,ELLIPSE,ARC"))))
 )
 (prompt "\nPick second curve")
 (while (not ss2)
   (setq ss2 (ssget "_+.:E:S:L" '((0 . "*LINE,RAY,XLINE,CIRCLE,ELLIPSE,ARC"))))
 )
 (setq c1 (ssname ss1 0))
 (setq c2 (ssname ss2 0))
 (initget 6)
 (setq n (cond ((getint "\nType number of spaces-segments between 2 curves <25> : "))
               ( 25 )
         )
 )
 (setq stpar (vlax-curve-getstartparam c1))
 (setq enpar (vlax-curve-getendparam c1))
 (setq ln -1)
 (while (tblsearch "LAYER" (setq lnstr (itoa (setq ln (1+ ln))))))
 (setq lnstr (itoa ln))
 (vl-cmdf "_.-layer" "m" lnstr "")
 (setvar 'clayer clay)
 (setq k -1)
 (repeat (+ n 1)
   (setq par (+ stpar (* (/ (- enpar stpar) (float n)) (float (setq k (1+ k))))))
   (setq p1 (vlax-curve-getpointatparam c1 par))
   (setq p2 (vlax-curve-getclosestpointto c2 p1))
   (if (/= k n)
     (progn
       (setq parr (+ stpar (* (/ (- enpar stpar) (float n)) (float (+ k 0.5)))))
       (setq p11 (vlax-curve-getpointatparam c1 parr))
       (setq p22 (vlax-curve-getclosestpointto c2 p11))
       (setq phor (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p11 p22))
       (setq anh (cvunit (angle p11 p22) "radians" "degrees"))
       (setq hdata (cons (cons anh phor) hdata))
     )
   )
   (setq lin (vla-addline msp (vlax-3d-point p1) (vlax-3d-point p2)))
   (vla-put-layer lin lnstr)
 )
 (foreach h hdata
   (vl-cmdf "_.-hatch" "p" "" "" (car h) "o" "s" (cdr h) "" (cdr h) "")
 )
 (prompt (strcat "\nDo you want to <E>rase or <L>eave lines on new layer \"" lnstr "\" : "))
 (initget 1 "Erase Leave")
 (setq ch (getkword))
 (if (eq ch "Erase") 
   (repeat (setq z (sslength (setq ssz (ssget "_X" (list '(0 . "LINE") (cons 8 lnstr))))))
     (entdel (ssname ssz (setq z (1- z))))
   )
 )
 (vl-cmdf "_.-purge" "LA" "" "n")
 (princ)
)
(defun c:hb2c nil (c:hatchbetween2curves))
(prompt "\nShortcut for c:hatchbetween2curves is c:hb2c")
(princ)

 

M.R.

Link to comment
Share on other sites

My opinion is that is possible to write such routine, but it will be an extremely complicated task. The routine will have to follow the median path and draw perpendicular on it each row of tiles – the size of tiles on each row need to be slightly adjusted (increased or decreased) from one end of the row to the other to allow the consecutive rows to fit together. Also take care to don't exceed the lateral limits. And all this for just esthetical purpose.

The said tile said size adjustment is similar with what the fitter workers will do in real life with the gap between rows.

 

yes, i know its a very complicated task....i hope Autodesk will consider this in their future releases..

 

All I can think is something like this routine :

 

(vl-load-com)
(defun c:hatchbetween2curves ( / msp clay hpn hps ss1 ss2 c1 c2 n stpar enpar ln lnstr k par parr p1 p2 p11 p22 phor anh hdata lin ch z ssz )
 (setq msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
 (setq clay (getvar 'clayer))
 (prompt (strcat "\nType HPNAME variable <" (getvar 'hpname) "> : "))
 (setq hpn (getstring))
 (if (not (eq hpn "")) (setvar 'hpname hpn))
 (prompt (strcat "\nType HPSCALE variable <" (rtos (getvar 'hpscale)) "> : "))
 (initget 6)
 (setq hps (getreal))
 (if (not (null hps)) (setvar 'hpscale hps))
 (prompt "\nPick first curve")
 (while (not ss1)
   (setq ss1 (ssget "_+.:E:S:L" '((0 . "*LINE,RAY,XLINE,CIRCLE,ELLIPSE,ARC"))))
 )
 (prompt "\nPick second curve")
 (while (not ss2)
   (setq ss2 (ssget "_+.:E:S:L" '((0 . "*LINE,RAY,XLINE,CIRCLE,ELLIPSE,ARC"))))
 )
 (setq c1 (ssname ss1 0))
 (setq c2 (ssname ss2 0))
 (initget 6)
 (setq n (cond ((getint "\nType number of spaces-segments between 2 curves <25> : "))
               ( 25 )
         )
 )
 (setq stpar (vlax-curve-getstartparam c1))
 (setq enpar (vlax-curve-getendparam c1))
 (setq ln -1)
 (while (tblsearch "LAYER" (setq lnstr (itoa (setq ln (1+ ln))))))
 (setq lnstr (itoa ln))
 (vl-cmdf "_.-layer" "m" lnstr "")
 (setvar 'clayer clay)
 (setq k -1)
 (repeat (+ n 1)
   (setq par (+ stpar (* (/ (- enpar stpar) (float n)) (float (setq k (1+ k))))))
   (setq p1 (vlax-curve-getpointatparam c1 par))
   (setq p2 (vlax-curve-getclosestpointto c2 p1))
   (if (/= k n)
     (progn
       (setq parr (+ stpar (* (/ (- enpar stpar) (float n)) (float (+ k 0.5)))))
       (setq p11 (vlax-curve-getpointatparam c1 parr))
       (setq p22 (vlax-curve-getclosestpointto c2 p11))
       (setq phor (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p11 p22))
       (setq anh (cvunit (angle p11 p22) "radians" "degrees"))
       (setq hdata (cons (cons anh phor) hdata))
     )
   )
   (setq lin (vla-addline msp (vlax-3d-point p1) (vlax-3d-point p2)))
   (vla-put-layer lin lnstr)
 )
 (foreach h hdata
   (vl-cmdf "_.-hatch" "p" "" "" (car h) "o" "s" (cdr h) "" (cdr h) "")
 )
 (prompt (strcat "\nDo you want to <E>rase or <L>eave lines on new layer \"" lnstr "\" : "))
 (initget 1 "Erase Leave")
 (setq ch (getkword))
 (if (eq ch "Erase") 
   (repeat (setq z (sslength (setq ssz (ssget "_X" (list '(0 . "LINE") (cons 8 lnstr))))))
     (entdel (ssname ssz (setq z (1- z))))
   )
 )
 (vl-cmdf "_.-purge" "LA" "" "n")
 (princ)
)
(defun c:hb2c nil (c:hatchbetween2curves))
(prompt "\nShortcut for c:hatchbetween2curves is c:hb2c")
(princ)

M.R.

 

Thanks for this!

tried out the lisp and here's what i got! (see attached image)

some minor problem with the pattern overlappings but hey! its closed!

Drawing1.jpg

Link to comment
Share on other sites

I’ve posted a mapping routine(.NET) that can simulate this functionality in this thread:

 

http://www.cadtutor.net/forum/showthread.php?41260-drawing-on-a-sphere

 

 

 

As a matter of fact, post #11 of that thread shows an example that uses the AR-HBONE.

 

The workflow is a bit convoluted but here is an example of the result. Each brick shows some curve/morphing, so it may not be appropriate. Perhaps not too bad if it is just for a visual.

Hatch.dwg

Link to comment
Share on other sites

Maybe I'm wrong, but I tried dll and after I select sphere I get error : Unable to acquire 3dsolid face...

I am using A2012 64 Win 7...

 

Can you help, Seant?

M.R.

 

Select face of solid:

Error while acquiring Face!

Edited by marko_ribar
Link to comment
Share on other sites

Yes. That particular version was written and tested with AutoCAD 2009 (32 bit). Even back then there were signs of incompatibility – see post 12 of that thread.

 

 

 

Unfortunately, I still cannot test against AutoCAD 2010-2011. I am refactoring the project, as well as a few more, for AutoCAD2012-2013 to eventually submit to Autodesk Exchange Apps.

Link to comment
Share on other sites

Just wait until the client actually wants it built. Should give someone a headache :shock:

 

actually this is giving me a lot of headache too hehe!

 

I’ve posted a mapping routine(.NET) that can simulate this functionality in this thread:

 

http://www.cadtutor.net/forum/showthread.php?41260-drawing-on-a-sphere

 

 

 

As a matter of fact, post #11 of that thread shows an example that uses the AR-HBONE.

 

The workflow is a bit convoluted but here is an example of the result. Each brick shows some curve/morphing, so it may not be appropriate. Perhaps not too bad if it is just for a visual.

 

thanks! i will try this one out!

Link to comment
Share on other sites

  • 3 weeks later...

Maybe, I don't know to manipulate so good with geometry??? I am arch., tried dlls on A2009 32 bit and it works, but I am unable to reproduce hatch Sean posted... My canvas block when select face has 2 shapes - inside shape follows curvatures and outside is boundary rectangle... When I hatch => explode and use "CVP" no deformations occurs - only lines have been transformed to splines... If only Sean can demonstrate with animated gif, what he did...

 

M.R.

Link to comment
Share on other sites

I think I figured out how to do it... Make solid with shape - half ellipse region positioned perpendicular to plline that is pedit=>splined as extrude path... NETLOAD => CPM => hatch => explode => CVP and that's it... Example I posted now is with half circle region shape and pline splined as extrude path with low number of vertices for curvature... But this explains whole process... It should project hatch on curved surface with CVP very fast... If it's slow something with surface is wrong - when unfolded result should always be rectangle...

 

M.R.:)

hatch-proj on curved surface.dwg

Edited by marko_ribar
attached dwg was corrupted, so it's replaced with good one
Link to comment
Share on other sites

I think I figured out how to do it... Make solid with shape - half ellipse region positioned perpendicular to plline that is pedit=>splined as extrude path... NETLOAD => CPM => hatch => explode => CVP and that's it... Example I posted now is with half circle region shape and pline splined as extrude path with low number of vertices for curvature... But this explains whole process... It should project hatch on curved surface with CVP very fast... If it's slow something with surface is wrong - when unfolded result should always be rectangle...

 

M.R.:)

 

yes...and it is limited to this hatch pattern only.

guess there is no way we can have hatch follow a path :sigh:

Link to comment
Share on other sites

You can get an approximate picture with creating several blocks and using Measure.

 

But in the real world, paviors are of fixed dimensions and are solid, so if the client sees the paviors following a curved path, and wants what he sees, you are going to have terrible problems making customised paving blocks. Better the client does not see some clever drafting, and you realise that your vision is going to cost an awful lot to achieve. However, if you have an unlimited budget, then go for it.

Link to comment
Share on other sites

If this is what you do for a living then go out and hire someone to write you a customized lisp program to hand the chore.

 

i did try hiring someone but still no avail

Link to comment
Share on other sites

 

thanks. I have seen this already but im afraid it is not applicable

 

 

Yes, i kinda know him (well most LISP users should know him)

He has quite a good reputation in field of lisp programming

i haven't asked him yet :)

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