Jump to content

Road Hatching


woodman78

Recommended Posts

I am creating a lisp for road hatching. This is what I have so far.

It works by selecting a base line and inserting a blocka long it using the measure command.

Create a selection set of the blocks and explode them.

Then select an outline and that is offset inside (the user selects the side to offset to. Can this default to inside?)

I need then to create a selection set of the exploded lines and to trim them from the offseted outline.

I am struggling with the last few bits and would appreciate some help.

Hatching.PNG

Link to comment
Share on other sites

First Dont use blocks for thick lines use plines extra work to trim a block.

 

Have a look at the command "extrim". It will trim inside or outside the chevrons normally dont touch the inside line so offset the inner for the trim line use "last" then erase "last" should remove it.

 

Just did manual draw island draw plines and copy etc offset island to inside EXTRIM L point out side all done E L finished. The main thing is pick start and end for pline orientation and make long enough to cover most islands. It took seconds to do from scratch.

 

Post code interested helping you I would use it.

Link to comment
Share on other sites

This is the code I have so far.

 

 
(defun C:hatch_lining (/ ang coords elist midp offsetted offsetted1 ofpt p1 p2 p3 pline side SUCE SUOM SUSM SUAB SUAD SUCL SUCR)
(setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))

(setq vl1 (list
 (cons 0 "LAYER")  ;Name of entity
 (cons 100 "AcDbSymbolTableRecord")     ;Open Records
 (cons 100 "AcDbLayerTableRecord")     ;Locate Layer Table
 (cons 2 "CCC_LAYOUT_Proposed_Road_Lining_Hatching")  ;Name of Layer
 (cons 6 "Continuous")      ;Linetype
 (cons 62 7)       ;colour = light grey
 (cons 70 0)       ;state
 (cons 290 1)       ;1=plot, 0=Don't plot
  )       ;End of entity list
 )
 (entmake vl1)
(command "_.-layer" "_C" "3" "CCC_LAYOUT_Proposed_Road_Lining_Hatching" "")
(setvar "clayer" "CCC_LAYOUT_Proposed_Road_Lining_Hatching")  
(setvar "cecolor" "1")
(setq pline(entsel "\nSelect an arc or a polyline: "))
(setq coords (vl-remove-if (function not)
(mapcar (function (lambda (x)
(if (= 10 (car x))(cdr x))))
elist))
)
(setq p2 (car coords)
midp (mapcar (function (lambda( a b)(/ (+ a b) 2)))
p1 p2)
)
(command "measure" pline "b" "hatch Lining" "y" "2" "")
(command "_change" pline ""  "p" "Layer" "CCC_LAYOUT_Proposed_Road_Lining_Hatching" "color" "Bylayer" "")
(setvar "qaflags" 1)
(setq SS1 (ssget "X" (list '(0 . "INSERT") (cons 2 "hatch Lining"))))
(command "explode" SS1 "")
(setvar "qaflags" 0)
(setq sel1 (ssget "x" '((8 . "CCC_LAYOUT_Proposed_Road_Lining_Hatching_Construction"))))
(setq outpline(entsel "\nSelect a closed polyline: "))
(setq inside(getpoint "\nPick an offset side: "))
(command "._offset" 0.3 outpline inside "")
(setq offsetted (entlast)
elist (entget offsetted)
)


 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"    SUCR)
(princ) 
)

Link to comment
Share on other sites

I have tried calling "extrim" using Command in the lisp but it doesn't work. How do I call it? And can I use a selection set of items to trim?

Link to comment
Share on other sites

I have worked manually with "cookiecutter2" from Joe Burke and it works great. How can I call it from my routine?

 

Example

(command "cookiecutter2")

Link to comment
Share on other sites

I got it sorted. I added to my file and called it then. I commented out the parts of cookiecutter2 I didn't need. It works fine.

Link to comment
Share on other sites

Here is the finished cde. I know it's not elegant and is very clunky but it does what I need it to do

 

I can't attach the blocks that create the lining but they are very simple. They are just plines passing through the origin at 45 degrees in both directions and about 6m either side of the origin.

Hatch_Lining.lsp

Link to comment
Share on other sites

The better way to do it is to create parallel lines = width of chevrons use extrim to offset inside of island then use hatch solid and it gives a perfect shape then to the arc sides.

 

And yes like you I could not get Extrim to work in plain lisp (command "extrim" "last" pt1) gives unknown command, any one have an idea ?

 

Yhen I can make the hatching automatic quite easy. Just get start pt of line end point of next line pick pt for hatch is half start-end.

Link to comment
Share on other sites

Bigal,

Parallel lines works fine if the hatching is along a straight but most of ours wouldn't be. I had trouble with the extrim and I saw somewhere on the web about loading it first within the lisp as a different name and calling the name as you need it. I couldn't find it again though. Even when I ran extrim manually though I had problems. I found cookiecutter2 to be much better. I commented out the parts that I didn't want and it works great.

Link to comment
Share on other sites

You are right if you have an arc of a tight radius the chevron should be at a correct angle to the point on the arc so the paired lines would rotate as they are copied along, it has to be paired lines as the road paint guys have cutouts of the painted width. It could be done but a lot more complicated in the automation. you could use circular array to achieve the result but a lot more maths involved.

 

Will think about it more and search for extrim answer.

 

Found an answer over at THESWAMP thanks to AlanJT

 

do the following

(load "extrim") ; its part of the express lisps

 

(setq pt1 (getpoint)) ; outside pick point

(setq objent (car (entsel))) ; pick trim pline

(etrim objent pt1)

 

should all be done add some prompts etc

Edited by BIGAL
found
Link to comment
Share on other sites

  • 3 weeks later...

Thanks Bigal but can I restrict extrim to only trim objects on a certain layer?

 

I want to be able to trim a selection set of polylines by selecting a trim line and a point outside the line. This can be in a heavily populated drawing and I fear extrim is a bit like using a chainsaw when a chisel will do!!!! It could cause untold damage by trimming other objects.

Link to comment
Share on other sites

Can Bigal's piece of code above be modified to trim the lines around the pline chosen and not just on one side?

Link to comment
Share on other sites

Does anyone have a routine that will isolate a layer based on layername and not on selecting a layer on screen?

 

Thanks.

Link to comment
Share on other sites

Does anyone have a routine that will isolate a layer based on layername and not on selecting a layer on screen?

 

I'm sure you could put one together using the LAYER command:

 

(command "_.-layer" "_OFF" "*" "_Y" "_ON" pause "")

Link to comment
Share on other sites

  • 3 years later...

Hi woodman78. I know it's been 3 years since your previous post. But I have question - did you finish lisp which draws the road cross hatch or chevron hatch? Can you tell me what is easiest way to draw this kind of marking in Civil 3D?

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