Author Topic: Match properties  (Read 5956 times)

0 Members and 1 Guest are viewing this topic.

jbaxter

  • Guest
Match properties
« on: December 20, 2006, 10:29:50 PM »
Greetings,

I am searching for a match properties lsp routine which will simply pick a source polyline and then apply the same characteristics to another single or selection set of polylines, layer,width,color,linetype etc.

Regards,
John

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Match properties
« Reply #1 on: December 20, 2006, 10:35:10 PM »
Something like MATCHPROP ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Guest

  • Guest
Re: Match properties
« Reply #2 on: December 21, 2006, 08:28:19 AM »
Been one of those weeks, huh John?  I know the feeling.   :-)

jbaxter

  • Guest
Re: Match properties
« Reply #3 on: December 21, 2006, 05:43:08 PM »
Yep, I am sure many drafties will sympathise with me.:-)

I do have the matchprop command however does not in particular match the polyline's width.

Regards,
JB

Guest

  • Guest
Re: Match properties
« Reply #4 on: December 21, 2006, 06:21:43 PM »
What version of ACAD?  I'm pretty sure '05 and up does that (I can't remember)

jbaxter

  • Guest
Re: Match properties
« Reply #5 on: December 21, 2006, 07:43:55 PM »
Hi,

I am using LDD3.

Regards,
JB

Guest

  • Guest
Re: Match properties
« Reply #6 on: December 22, 2006, 08:43:17 AM »
Well aren't you just SOL?

I'll see if I can throw something together (unless someone else already has something they'd like to share) but I can't promise anything; not today anyways.  Today is our annual Holiday Drink-Fest in the office!!


Kate M

  • Guest
Re: Match properties
« Reply #7 on: December 22, 2006, 01:54:42 PM »
Is LDD3 based on the 2000 family? (2004 will match polyline widths.)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #8 on: December 23, 2006, 12:47:43 PM »
John,
No time, but here is a quickie.
No guarantees. :)
Merry Christmas
Code: [Select]
(defun C:mPOLY (/ colr ename ent i lay ltyp obj ss typ wid)
  (if (setq ent (nentsel "\nSelect source polyline: "))
    (progn
      (setq obj (vlax-ename->vla-object (car ent))
            typ (substr (vla-get-objectname obj) 5) )
      (if (vl-position (strcase typ) '("POLYLINE" "2DPOLYLINE"))

        (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 lay (vla-get-layer obj)
                ltyp (vla-get-Linetype obj)
                colr (vla-get-color obj)
                )
          (while
            (progn
              (prompt "\nSelect plines to change.")
              (setq ss (ssget '((0 . "Polyline,LWpolyline"))))
              (if (null ss)
                (princ "\nNothing selected, Try again.")
              )
            )
          )
       (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         ;; update plines
         (setq obj (vlax-ename->vla-object ename))
         (vla-put-ConstantWidth obj wid)
         (vla-put-layer obj lay)
         (vla-put-Linetype obj ltyp)
         (vla-put-color obj colr)
       )
         
        ) ; progn
        (prompt "\nNot a polyline")
      )
    )
  )
  (princ)
)
« Last Edit: January 08, 2007, 08:19:45 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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #9 on: December 24, 2006, 09:43:00 AM »
Maybe this would be better.
Still not much testing

Code: [Select]
;;  Match Polyline.lsp
;;  CAB  01/08/2007
;;  Honer Locked Layers
(defun C:mPOLY () (MatchPOLY nil))
;;  Over ride locked layers
(defun C:mPOLYL () (MatchPOLY t))
;;  Main function
;;  match Properties
;;    layer
;;    linetype
;;    global width
(defun MatchPOLY (UnLock        /       colr    ename   ent     i
                  lay     ltyp    obj   ss      typ     wid     Locked
                  lokt    doc     FoundLocked   Layers
                 )
  (vl-load-com)
  (if (setq ent (entsel "\nSelect source polyline: "))
    (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 (car ent))
            typ (substr (vla-get-objectname obj) 5)
            lay (vla-get-layer obj)
            Layers (vla-get-Layers doc)
      )
      (if (and (vl-position (strcase typ) '("POLYLINE" "2DPOLYLINE"))
               (= (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)
          (if (/= locked :vlax-true)
            (progn
              (while
                (progn
                  (prompt "\nSelect plines to change.")
                  (setq ss (ssget '((0 . "Polyline,LWpolyline"))))
                  (if (null ss)
                    (princ "\nNothing selected, Try again.")
                  )
                )
              )
              (setq i -1)
              (while (setq ename (ssname ss (setq i (1+ i))))
                ;; 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)
                  )
                )
              )
            )
          )
          (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)
)

« Last Edit: January 08, 2007, 08:18:33 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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Match properties
« Reply #10 on: December 24, 2006, 07:26:06 PM »
JB,
just for interest, what does the help in LDD show for MATCHPROP ?

Here are some piccys from the AC2006 help.
I am bemused why the function is different in each application ...  :?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jbaxter

  • Guest
Re: Match properties
« Reply #11 on: January 04, 2007, 06:40:57 AM »
Maybe this would be better.
Still not much testing

Code: [Select]
;;  Match Polyline.lsp
;;  CAB  12/24/2006............................

Hi,

Thanks all for your help, back to the grind on Monday so will give it a try then.

Kind Regards & Happy New Year,
JB
« Last Edit: February 06, 2007, 05:12:09 PM by Maverick® »

jbaxter

  • Guest
Re: Match properties
« Reply #12 on: January 07, 2007, 06:27:11 PM »
JB,
just for interest, what does the help in LDD show for MATCHPROP ?


Hi,

The help describes a lineweight toggle under settingd for the command but does not seem to operate, that is, it does not trnasfer the width feature from source to target.

Regards,
John
« Last Edit: February 06, 2007, 05:10:43 PM by Maverick® »

jbaxter

  • Guest
Re: Match properties
« Reply #13 on: January 07, 2007, 06:28:58 PM »
Maybe this would be better.
Still not much testing

Code: [Select]
;;  Match Polyline.lsp
;;  CAB  12/24/2006
;;  Honer Locked Layers
(defun C:mPOLY () (MatchPOLY nil))
;;  Over ride locked layers
(defun C:mPOLYL () (MatchPOLY t))


Hi,

I am getting the following when selecting the source, it IS a pline and not on a locked layer.

Regards,
JB

Command: mpoly

Select source polyline:
Not a polyline, or Locked layer.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Match properties
« Reply #14 on: January 07, 2007, 07:10:31 PM »
Attach a sample drawing.
Which pline in the drawing are you trying to select?
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 #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.