Author Topic: Dashed Linetype with a width  (Read 3213 times)

0 Members and 1 Guest are viewing this topic.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Dashed Linetype with a width
« on: July 06, 2012, 01:38:34 PM »
Does anyone have a lisp that will create a linetype sim to below?
(with the exception of the boss wanting the solid part to be .5 the distance of the gap). It will for civil site plans dipicting a utility, dont know what the scale on the sheets will be yet so may need a line 12"  wide or 12'

Thx's!

Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Dashed Linetype with a width
« Reply #1 on: July 06, 2012, 01:41:01 PM »
The way we've handled that in the past was to have three polylines (two on the outside with a width of zero, and the interior polyline with a width equaling the spacing between the two outer polylines).  We had a custom LSP that created everything for us.

You could probably also an mline??  It's been a while since I've used them so I'm not 100% sure.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Dashed Linetype with a width
« Reply #2 on: July 06, 2012, 02:05:27 PM »
Yea, I've seen maps where someone would use a mline (say width = 1) and between the line have a dashed pline (width = 1). Sounds same as your method, but what does your lsp do for you?

Due to the number of lines a single lt would be much easier, but a 3 line method is still do-able.
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Dashed Linetype with a width
« Reply #3 on: July 06, 2012, 02:21:48 PM »
Quick hack:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:3line ( / *error* en lt ltype ob pw width )
  2.  
  3.     (setq ltype "HIDDEN" ;; Linetype for center polyline
  4.           width 12.0     ;; Width for center polyline
  5.     )
  6.  
  7.     (defun *error* ( msg )
  8.         (if lt (setvar 'celtype lt))
  9.         (if pw (setvar 'plinewid pw))
  10.         (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  11.             (princ (strcat "\nError: " msg))
  12.         )
  13.         (princ)
  14.     )
  15.  
  16.     (setq lt (getvar 'celtype)
  17.           pw (getvar 'plinewid)
  18.     )
  19.     (if (tblsearch "LTYPE" ltype)
  20.         (setvar 'celtype ltype)
  21.     )
  22.     (setvar 'plinewid width)
  23.     (setq en (entlast))
  24.     (command "_.pline")
  25.     (while (= 1 (logand 1 (getvar 'cmdactive)))
  26.         (command pause)
  27.     )
  28.     (if (not (eq en (setq en (entlast))))
  29.         (progn
  30.             (setq en (vlax-ename->vla-object en))
  31.             (foreach of (list (/ width 2.0) (/ width -2.0))
  32.                 (setq ob (car (vlax-invoke en 'offset of)))
  33.                 (vla-put-linetype ob "CONTINUOUS")
  34.                 (vla-put-constantwidth ob 0.0)
  35.             )
  36.         )
  37.     )
  38.     (setvar 'celtype lt)
  39.     (setvar 'plinewid pw)
  40.     (princ)
  41. )
« Last Edit: July 06, 2012, 03:02:09 PM by Lee Mac »

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Dashed Linetype with a width
« Reply #4 on: July 06, 2012, 02:30:09 PM »
Here's my "hack"   :-)

It will create your linetype that has a gap that's twice as long as the dash. LTSCALE will determine the actual length.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:xx (/ _drawpline e w o pw)
  2.   (defun _drawpline (/ tmp)
  3.     (setq tmp (entlast))
  4.     (command "_.pline")
  5.     (while (> (getvar 'cmdactive) 0) (command pause))
  6.     (if (not (equal tmp (entlast)))
  7.       (entlast)
  8.     )
  9.   )
  10.   (setq pw (getvar 'plinewid))
  11.   (if (and (setq w (getdist "\nEnter width for polyline: "))
  12.            (not (zerop w))
  13.            (setvar 'plinewid w)
  14.            (setq e (_drawpline))
  15.       )
  16.     (progn (entmakex '((0 . "LTYPE")
  17.                        (100 . "AcDbSymbolTableRecord")
  18.                        (100 . "AcDbLinetypeTableRecord")
  19.                        (2 . "Custom_LT")
  20.                        (70 . 0)
  21.                        (3 . "Custom_LT __ __ __")
  22.                        (72 . 65)
  23.                        (73 . 2)
  24.                        (40 . 1.0)
  25.                        (49 . 0.5)
  26.                        (74 . 0)
  27.                        (49 . -1.0)
  28.                        (74 . 0)
  29.                       )
  30.            )
  31.            (setq o (vlax-ename->vla-object e))
  32.            (vla-put-constantwidth o w)
  33.            (vla-put-linetype o "Custom_LT")
  34.            (mapcar '(lambda (off)
  35.                       (setq o (car (vlax-invoke (vlax-ename->vla-object e) 'offset off)))
  36.                       (vla-put-constantwidth o 0)
  37.                       (vla-put-linetype o "continuous")
  38.                       (vla-put-color o 1)
  39.                     )
  40.                    (list (* 0.5 w) (- (* 0.5 w)))
  41.            )
  42.            (setvar 'plinewid pw)
  43.     )
  44.   )
  45.   (princ)
  46. )
« Last Edit: July 06, 2012, 02:39:50 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Dashed Linetype with a width
« Reply #5 on: July 06, 2012, 02:50:19 PM »
You guys always amaze me.

Lee, I couldn't get a dash space dash, I'm prob not looking at the options close enough
Ron: at the risk of looking a gift horse........ is there a way to shorten the solid dash or increase the space between dashes (so the dash is 1/2 the distance of the space). From very limited knowledge is the spacing defined somewhere between lines 22 - 27?

Thx's always!

(If I could do in a week what you guys hack out, I could die happy)
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Dashed Linetype with a width
« Reply #6 on: July 06, 2012, 02:55:20 PM »
Try copying the code again. This is the result I get.  :-)


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Dashed Linetype with a width
« Reply #7 on: July 06, 2012, 03:00:55 PM »
Lee, I couldn't get a dash space dash, I'm prob not looking at the options close enough

With the current settings, my code will assign the HIDDEN Linetype to a center polyline with a width of 12 units (noted at the top of the code). If the HIDDEN Linetype is not loaded, it will use continuous.

As with Ron's, the gap size will be dependent on your setting of LTSCALE  :-)

(If I could do in a week what you guys hack out, I could die happy)

Thanks, though we've had too much practice  :-)

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: Dashed Linetype with a width
« Reply #8 on: July 06, 2012, 03:46:53 PM »
Got it :)

Dependent on what scale the Boss ends up using I may experiment with the numbers.
1. Is it lines 24 and 25 that dictate the space and dash?
2. To give proper credit can I put Lee Mac and Ronjonp in  the code?
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Dashed Linetype with a width
« Reply #9 on: July 06, 2012, 04:07:00 PM »
The lines are 24,25 and 27 to adjust the gaps and spaces.

Have fun  8-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dashed Linetype with a width
« Reply #10 on: July 06, 2012, 06:33:16 PM »
Cool stuff, I'd like to see a pick pline for center & new plines created to match, deleting the source pline.
And to handle arcs.  :evil:

Love to join in but off for a week.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Dashed Linetype with a width
« Reply #11 on: July 07, 2012, 06:00:06 AM »
2. To give proper credit can I put Lee Mac and Ronjonp in  the code?

Thank you, that's very honourable of you  :-)

Cool stuff, I'd like to see a pick pline for center & new plines created to match, deleting the source pline.
And to handle arcs.  :evil:

Love to join in but off for a week.

Cheers Alan, give this a try:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:3line ( / *error* _processpoly ent inc ltp olt opw pt1 sel wid )
  2.      
  3.     (setq ltp "HIDDEN" ;; Linetype for center polyline
  4.           wid 12.0     ;; Width for center polyline
  5.     )
  6.  
  7.     (defun *error* ( msg )
  8.         (if olt (setvar 'celtype  olt))
  9.         (if opw (setvar 'plinewid opw))
  10.         (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  11.             (princ (strcat "\nError: " msg))
  12.         )
  13.         (princ)
  14.     )
  15.  
  16.     (defun _processpoly ( obj ltp wid / new )
  17.         (vla-put-linetype obj ltp)
  18.         (vla-put-constantwidth obj wid)
  19.         (foreach off (list (/ wid 2.0) (/ wid -2.0))
  20.             (setq new (car (vlax-invoke obj 'offset off)))
  21.             (vla-put-linetype new "CONTINUOUS")
  22.             (vla-put-constantwidth new 0.0)
  23.         )
  24.     )                                    
  25.  
  26.     (if (null (tblsearch "LTYPE" ltp))
  27.         (setq ltp "CONTINUOUS")
  28.     )
  29.     (initget "Select")
  30.     (cond
  31.         (   (null (setq pt1 (getpoint "\nSpecify start point [Select]: ")))
  32.         )
  33.         (   (= "Select" pt1)
  34.             (while
  35.                 (progn
  36.                     (setvar 'errno 0)
  37.                     (initget "Multiple")
  38.                     (setq ent (entsel "\nSelect LWPolyline [Multiple]: "))
  39.                     (cond
  40.                         (   (= 7 (getvar 'errno))
  41.                             (princ "\nMissed, try again.")
  42.                         )
  43.                         (   (= "Multiple" ent)                    
  44.                             (if (setq sel (ssget "_:L" '((0 . "LWPOLYLINE"))))
  45.                                 (repeat (setq inc (sslength sel))
  46.                                     (_processpoly (vlax-ename->vla-object (ssname sel (setq inc (1- inc)))) ltp wid)
  47.                                 )
  48.                             )
  49.                             nil
  50.                         )
  51.                         (   (= 'ename (type (car ent)))
  52.                             (if (= "LWPOLYLINE" (cdr (assoc 0 (entget (car ent)))))
  53.                                 (_processpoly (vlax-ename->vla-object (car ent)) ltp wid)
  54.                                 (princ "\nInvalid Object Selected.")
  55.                             )
  56.                         )
  57.                     )
  58.                 )
  59.             )
  60.         )
  61.         (   t
  62.             (setq olt (getvar 'celtype)
  63.                   opw (getvar 'plinewid)
  64.             )
  65.             (setvar 'celtype  ltp)
  66.             (setvar 'plinewid wid)
  67.             (setq ent (entlast))
  68.             (command "_.pline" "_non" pt1)
  69.             (while (= 1 (logand 1 (getvar 'cmdactive)))
  70.                 (command pause)
  71.             )
  72.             (if (not (eq ent (setq ent (entlast))))
  73.                 (_processpoly (vlax-ename->vla-object ent) ltp wid)
  74.             )
  75.             (setvar 'celtype  olt)
  76.             (setvar 'plinewid opw)
  77.         )
  78.     )
  79.     (princ)
  80. )

GDF

  • Water Moccasin
  • Posts: 2081
Re: Dashed Linetype with a width
« Reply #12 on: July 08, 2012, 03:20:49 PM »
Pretty slick.

You might add offset from center between two lines or plines and controlling the pline width.

I have a dialog interface that will draw the dashed pline, or offset a dashed pline, now I can add a third option of drawing a dashed pline between the drawn bordering plines.

Anyway, thanks for sharing. I always learn from you guys.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Dashed Linetype with a width
« Reply #13 on: July 08, 2012, 03:35:39 PM »
Nice dialog Gary, as always  8-)