Jump to content

MATCHPROP layer...


Temy

Recommended Posts

Hi all,

In a drawing there is a class, but in that layer contains many different properties. I want to synchronize them into an attribute according to the attribute I choose as a template. Want to describe but it's hard to understand, Something similar to the image I have attached below.

can somebody help me please?

thanks

Cover Matchprop.JPG

Link to comment
Share on other sites

Try this. It will only pick Lines with the same linetype as the Template Line

 

(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst ltype p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'layer 'linetypescale 'lineweight 'truecolor)
        ltype (vlax-get t_obj 'linetype)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "LINE") (cons 6 ltype)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun
  

 

Link to comment
Share on other sites

14 hours ago, dlanorh said:

Try this. It will only pick Lines with the same linetype as the Template Line

 


(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst ltype p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'layer 'linetypescale 'lineweight 'truecolor)
        ltype (vlax-get t_obj 'linetype)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "LINE") (cons 6 ltype)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun
  

 

 

thank you for your reply! I tried it and it didn't work as expected. the problem is: The entire selected object has changed!

Please check it for me!

Cover Matchprop1.JPG

Cover Matchprop1.dwg

Edited by Temy
Link to comment
Share on other sites

12 hours ago, Temy said:

 

thank you for your reply! I tried it and it didn't work as expected. the problem is: The entire selected object has changed!

Please check it for me!

Cover Matchprop1.JPG

Cover Matchprop1.dwg 55.81 kB · 2 downloads

 

OK. With a drawing I can see why the first version didn't work properly, mainly through my stupidity. :cry:

 

Try this.

 

(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst lyr p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'linetypescale)
        lyr (vlax-get t_obj 'layer)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "LINE") (cons 8 lyr)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun

 

This will only select lines on the same layer as the "template" line.

  • Thanks 1
Link to comment
Share on other sites

On 2/29/2020 at 8:43 PM, dlanorh said:

 

OK. With a drawing I can see why the first version didn't work properly, mainly through my stupidity. :cry:

 

Try this.

 


(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst lyr p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'linetypescale)
        lyr (vlax-get t_obj 'layer)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "LINE") (cons 8 lyr)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun

 

This will only select lines on the same layer as the "template" line.

 

good good good. It works very well, Thanks very much!!!

Link to comment
Share on other sites

After using it I want it more than that, You help me develop more functionality for it

I want it to accept arc, circle, splines...It would be great if it worked like that. Please help me again

pipe.jpg

pipe.dwg

Link to comment
Share on other sites

(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst lyr p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'linetypescale)
        lyr (vlax-get t_obj 'layer)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "*LINE,ARC,CIRCLE,ELLIPSE") (cons 8 lyr)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun

If I've missed something let me know

  • Thanks 1
Link to comment
Share on other sites

15 hours ago, dlanorh said:

(vl-load-com)

(defun c:mltp ( / *error* c_doc c_spc sv_lst sv_vals t_obj p_lst lyr p_vals ss cnt obj)

  (defun *error* (msg)
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
    (princ)
  );end_error_on_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst (list 0 0))

  (setq t_obj (vlax-ename->vla-object (car (entsel "\nSelect Template Line : ")))
        p_lst (list 'linetypescale)
        lyr (vlax-get t_obj 'layer)
  );end_setq

  (mapcar '(lambda (x) (setq p_vals (cons (vlax-get-property t_obj x) p_vals))) p_lst)

  (setq p_vals (reverse p_vals)
        ss (ssget (list '(0 . "*LINE,ARC,CIRCLE,ELLIPSE") (cons 8 lyr)))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))))
            (mapcar '(lambda (x y) (vlax-put-property obj x y)) p_lst p_vals)
          );end_repeat
        )
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
  );end_defun

If I've missed something let me know

 

You are excellent! It works nicely!

Thanks a lot!

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