Temy Posted February 28, 2020 Share Posted February 28, 2020 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 Quote Link to comment Share on other sites More sharing options...
dlanorh Posted February 28, 2020 Share Posted February 28, 2020 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 Quote Link to comment Share on other sites More sharing options...
Temy Posted February 29, 2020 Author Share Posted February 29, 2020 (edited) 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.dwg Edited February 29, 2020 by Temy Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted February 29, 2020 Share Posted February 29, 2020 (edited) Deleted. Edited February 29, 2020 by Roy_043 Quote Link to comment Share on other sites More sharing options...
dlanorh Posted February 29, 2020 Share Posted February 29, 2020 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.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. 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. 1 Quote Link to comment Share on other sites More sharing options...
Temy Posted March 2, 2020 Author Share Posted March 2, 2020 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. 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!!! Quote Link to comment Share on other sites More sharing options...
Temy Posted March 2, 2020 Author Share Posted March 2, 2020 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.dwg Quote Link to comment Share on other sites More sharing options...
dlanorh Posted March 2, 2020 Share Posted March 2, 2020 (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 1 Quote Link to comment Share on other sites More sharing options...
Temy Posted March 3, 2020 Author Share Posted March 3, 2020 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.