Jump to content

LISP INCREASE INTERNAL CONSECUTIVELY IN BLOCK FROM OD


BRIAM RAMON

Recommended Posts

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 by BRIAM RAMON
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

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!

Link to comment
Share on other sites

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

 

Capture.JPG

  • Like 1
Link to comment
Share on other sites

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

 

image.thumb.png.a91caff58bc054d7890ecc9f1df8ff54.png

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