Author Topic: Match properties  (Read 5954 times)

0 Members and 1 Guest are viewing this topic.

jbaxter

  • Guest
Re: Match properties
« Reply #15 on: January 08, 2007, 04:54:56 AM »
I have just opened up a fresh blank screen, created a polyline with pline command and width of say 0.2 with pedit , spline smoothed it, and then created another polyline with width 0.0 and spline smoothed.

Next applied the mpoly routine however rejects the source polyline.

Regards,
John

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #16 on: January 08, 2007, 08:20:54 AM »
John,
I updated the code. Copy & try it again.
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.

jbaxter

  • Guest
Re: Match properties
« Reply #17 on: January 08, 2007, 11:40:10 PM »
Hi,

Where is the code? :-)

regards,
JB

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
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.

jbaxter

  • Guest
Re: Match properties
« Reply #19 on: January 09, 2007, 07:25:02 PM »
Thanks you. That worked a treat, appreciate your help with it.

Regards,
JB

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #20 on: January 10, 2007, 08:00:05 AM »
You're quite welcome.
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.

M-dub

  • Guest
Re: Match properties
« Reply #21 on: February 08, 2007, 01:27:15 PM »
Just a suggestion, but how difficult would it be to automatically turn LINES into POLYLINES if they aren't already.  You know how when you do a Pedit and it says "Object selected is not a polylineDo you want to turn it into one? <Y>"

Again, just a suggestion.  :)

Kate M

  • Guest
Re: Match properties
« Reply #22 on: February 08, 2007, 02:46:40 PM »
PEDITACCEPT, available in 2004+. Upgrade already! :-D

Josh Nieman

  • Guest
Re: Match properties
« Reply #23 on: February 08, 2007, 03:19:21 PM »
Just a suggestion, but how difficult would it be to automatically turn LINES into POLYLINES if they aren't already.  You know how when you do a Pedit and it says "Object selected is not a polylineDo you want to turn it into one? <Y>"

Again, just a suggestion.  :)

you know how much I'd love that?  I don't even see the point of drawing a line anymore... plines are so much superior.

M-dub

  • Guest
Re: Match properties
« Reply #24 on: February 08, 2007, 03:24:21 PM »
PEDITACCEPT, available in 2004+. Upgrade already! :-D


:lmao:


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #25 on: February 08, 2007, 05:44:28 PM »
Must be a better way to convert a line but this will do for now.
Code: [Select]
;;  Match Polyline.lsp
;;  CAB  01/08/2007
;;  Rev 3 02/09/2007
;;  Convert LINES to plines when selected

(defun C:mPOLY () (MatchPOLY nil nil)) ;  Honer Locked Layers
(defun C:mPOLYL () (MatchPOLY t nil)) ;  Over ride locked layers
(defun C:mPOLY+ () (MatchPOLY nil t)) ;  Honer Locked Layers & convert lines
(defun C:mPOLYL+ () (MatchPOLY t t)) ;  Over ride locked layers & convert lines

;;=====================================================
;;  Main function                                     
;;  match Properties -> layer, linetype, global width 
;;=====================================================

(defun MatchPOLY (UnLock   lflag     /       colr    ename   ent     i
                  lay     ltyp    obj   ss      typ     wid     Locked
                  lokt    doc     FoundLocked   Layers  filter  pt
                  elst    objlay  dellst
                 )
  (vl-load-com)
  (if UnLock
    (setq pkFilter "_+.:E:S")
    (setq pkFilter "_+.:E:S:L")
  )
  (if lflag
    (setq filter '((0 . "Polyline,LWpolyline,Line")))
    (setq filter '((0 . "Polyline,LWpolyline")))
  )
  (prompt "\nSelect pline to copy from.")
  (if (setq ss (ssget pkFilter '((0 . "Polyline,LWpolyline"))))
    (progn
      (vla-startundomark
        (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      )
      (if UnLock ; Unlock layers
        (vlax-for lay (vla-get-layers doc)
          (if (= (vla-get-lock lay) :vlax-true)
            (progn
              (setq lokt (cons lay lokt))
              (vla-put-lock lay :vlax-false)
            )
          )
        )
      )
      (setq obj (vlax-ename->vla-object (ssname ss 0))
            typ (substr (vla-get-objectname obj) 5)
            lay (vla-get-layer obj)
            Layers (vla-get-Layers doc)
      )
      (if (= (vla-get-Lock (vla-Item Layers lay)) :vlax-false)
        (progn
          (if (vl-catch-all-error-p
                (setq wid (vl-catch-all-apply 'vla-get-constantwidth (list obj)))
              )
            (progn
              (princ "\nWidth varies, setting to ")
              (princ (setq wid 0))
            )
          )
          (setq ltyp   (vla-get-linetype obj)
                colr   (vla-get-color obj)
          )
          (setq FoundLocked 0)
          (while
            (progn
               (prompt "\n**  Select plines to change.  **")
               (setq ss (ssget ":L" Filter)) ; ignore locked layers
               (if (null ss)
                 (princ "\nNothing selected, Try again.")
               )
             )
          )
          (setq i -1)
          (while (setq ename (ssname ss (setq i (1+ i))))
            (if (and lflag (= (cdr (assoc 0 (setq elst (entget ename)))) "LINE"))
              ;;  convert LINE to a LW pline
              (progn
                (foreach n '(-2 -1 0 5 100 102 300 330 331 350 360)
                  (while (assoc n elst)
                    (setq elst (vl-remove (assoc n elst) elst))
                  )
                )
                (setq elst (append '((0 . "LWPOLYLINE")(100 . "AcDbEntity")
                                     (100 . "AcDbPolyline")) elst))
                (setq pt (assoc 10 elst))
                (setq elst (vl-remove pt elst))
                (setq elst (append elst (list '(90 . 2) '(70 . 0) '(43 . 0.0)
                                              '(38 . 0.0) '(39 . 0.0) pt '(40 . 0.0)
                                              '(41 . 0.0) '(42 . 0.0))))
                (setq pt (assoc 11 elst))
                (setq elst (vl-remove pt elst))
                (setq elst (append elst (list (cons 10 (cdr pt)) '(40 . 0.0)
                                              '(41 . 0.0) '(42 . 0.0))))
                (entmake elst)
                (setq dellst (cons ename DelLst))
                (setq ename (entlast))
              )
            )
            ;; update plines
            (setq obj (vlax-ename->vla-object ename))
            (setq objlay (vla-get-layer obj))
            (if (= (vla-get-Lock (vla-Item Layers objlay)) :vlax-true)
              (setq FoundLocked (1+ FoundLocked))
              (progn
                (vla-put-constantwidth obj wid)
                (vla-put-layer obj lay)
                (vla-put-linetype obj ltyp)
                (vla-put-color obj colr)
              )
            )
          )
          (and DelLst (mapcar 'entdel DelLst))
          (if lokt ; relock layers
            (foreach lay lokt
              (vla-put-lock lay :vlax-true)
            )
          )
          (if (not (zerop FoundLocked))
            (prompt
              (strcat "\nFound " (itoa FoundLocked) " objects on locked layers.")
            )
          )
          (vla-endundomark doc)
        ) ; progn
        (prompt "\nNot a polyline, or Locked layer.")
      )
    )
  )
  (princ)
)

<edit: updated code>
« Last Edit: February 09, 2007, 09:24:46 AM by CAB »
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.

sinc

  • Guest
Re: Match properties
« Reply #26 on: February 08, 2007, 06:14:48 PM »
you know how much I'd love that?  I don't even see the point of drawing a line anymore... plines are so much superior.

In Civil-3D, the PLINE is a standard tool, used for all kinds of things.  But it doesn't work for everything.  With PLINE, the Z-value (elevation) of the pline is set by the first point in the PLINE, and then remains the same for every other point in the PLINE.  So the first point in the PLINE will snap to the X,Y,Z of the point you select.  But for the rest of the vertices, OSNAPing to points only takes the X and Y values from the OSNAP, and the Z value is the same as it was for the first vertex in the PLINE.

So for some things in C3D, I have to use 3DPOLY instead.  For example, if I want to complete a survey figure (such as a sidewalk) so that it forms an enclosed area that I can hatch, I will use 3DPOLY on a no-plot layer to complete the figure, and snap both ends of the 3DPOLY to the survey figure(s).  Then C3D can find a valid hatch boundary, and create the hatch.