Author Topic: Match properties  (Read 5955 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.