BRIAM RAMON Posted February 11, 2022 Posted February 11, 2022 (edited) Hi! With the help of the autodesk forum I have this lisp that consecutively increments a numeric value in a specific field of OD, also copies the block name to another field of the same OD. This lisp assigns the internal consecutively when the field INTERNO_SENAL has a data type of character, can the same process be done when the type of the OD field is as internal? Having this lisp is it possible that the value of INTERNO_SENAL is also copied in the INTERNO attribute of the block? ADD_ID.lsp Edited February 11, 2022 by BRIAM RAMON Quote
BRIAM RAMON Posted February 11, 2022 Author Posted February 11, 2022 I share the .dwg filep.ej.dwg Quote
Linh Posted February 12, 2022 Posted February 12, 2022 (defun c:addid1 (/ n inc enam idd efn) (setq tn "SDM_SEN_SENALIZACION") ;nombre de la tabla fijo. (prompt "Seleccionar señales") (princ) (setq n (getint "\n Ingrese valor de Inicio: ") ss (ssget '((0 . "insert"))) ) (setq inc 0) (repeat (setq len (sslength ss)) (setq enam (ssname ss inc)) (setq idd (itoa n)) (setq efn(vla-get-effectivename(vlax-ename->vla-object enam))) (ade_odaddrecord enam tn) (ade_odsetfield enam tn "INTERNO_SENAL" 0 idd) (ade_odsetfield enam tn "TIPO_SENAL" 0 efn) (command "chprop" enam "" "c" "ByLAyer" "") ;.... talvez no sea necesario...??? (setq inc (1+ inc) n (1+ n) ) ) (alert "Se actualizaron las entidades seleccionadas con INTERNO_SENAL") (princ) ) I am not sure what you mean. What is OD? And looking like "field" you means "attribute", in the language of AutoCAD? Or it is really "field"? For the information, above is the lisp ADD_ID.lsp, quite short so it can be easily pasted in the post. In the lisp, unknown functions are: (ade_odaddrecord ...) (ade_odsetfield ...) 1 Quote
BRIAM RAMON Posted March 1, 2022 Author Posted March 1, 2022 Hi! @Linh here you can find the functions https://documentation.help/AutoCAD-Map-3D-2009-AutoLISP/ade_function_catalog.htm What I need is to copy the value of the INTERNO_SENAL field of an Object Data (OD) to the attribute or field with INTERNO name of the blocks that I have selected. That is, add this function to the lisp that I share at the beginning of the publication. Thank you very much! Quote
hosneyalaa Posted March 2, 2022 Posted March 2, 2022 TRY LISP I notice to field type (defun c:AAaddid1 (/ n inc enam idd efn) (setq tn "SDM_SEN_SENALIZACION") (prompt "Seleccionar señales") (princ) (setq n (getint "\n Ingrese valor de Inicio: ") ss (ssget '((0 . "insert"))) ) (setq inc 0) (repeat (setq len (sslength ss)) (setq enam (ssname ss inc)) (setq idd (itoa n)) (setq efn(vla-get-effectivename(vlax-ename->vla-object enam))) (ade_odaddrecord enam tn) (ade_odsetfield enam tn "INTERNO_SENAL" 0 n) (ade_odsetfield enam tn "TIPO_SENAL" 0 efn) (command "chprop" enam "" "c" "ByLAyer" "") (setq inc (1+ inc) n (1+ n) ) ) (alert "The entities selected with INTERNO_SENAL were updated") (princ) ) 1 Quote
BRIAM RAMON Posted March 2, 2022 Author Posted March 2, 2022 Hi! @hosneyalaa Thank you very much, it works for the data type, it would only be necessary to add in this lisp the way to copy the value of the INTERNO_SENAL field to the INTERNO attribute of the block. I have been working on this lisp to achieve it. (defun c:FOO (/ ss) (vl-load-com) (if (setq ss (ssget '((0 . "INSERT")))) ((lambda (i / e s od r v n d tag) (setq i 0) (while (setq e (ssname ss (setq i (1+ i)))) ;; Extract object data (setq b (ade_odgetfield e (setq od (car (ade_odgettables e))) "INTERNO_SENAL" 0)) ;; Populate attributes (if (and (setq n (vla-get-effectivename (setq v (vlax-ename->vla-object e)))) (setq d (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) n))) (foreach attrib (vlax-invoke v 'getattributes) (vlax-for item d (if (= (vla-get-objectname item) "AcDbAttributeDefinition") (if (= (vla-get-tagstring attrib) (vla-get-tagstring item)) (cond ((= "INTERNO" (setq tag (vla-get-tagstring item))) (vla-put-textstring attrib b)))))))) )) -1)) (princ)) Quote
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.