Jump to content

Recommended Posts

Posted (edited)

I would like to merge the lisps I show at the end into one, where the process is first ADDID.lsp and then OD2ATT.lsp

 

If it were possible with your help to add a new functionality to addid.lsp and that is that when you copy the block name in the TIPO_SENAL field of the Object Data
You can check the block name to be able to change it to another, with some examples it would be enough to add as many times as this operation is necessary.

 

thank you very much, greetings

 

....

(defun c:ADDID (/ 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)
)

....

(defun c:OD2ATT  (/ ss)
 (vl-load-com)
(if (setq ss (ssget '((0 . "INSERT") (2 . "`*U*"))))
   ((lambda (i / e s od r v n d tag)
      (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))

 

ADDID.lsp OD2ATT.lsp eg.dwg

Edited by BRIAM RAMON
  • BRIAM RAMON changed the title to LISP: Increase consecutive number & Object data to block attribute
  • 3 weeks later...
Posted

 

I was able to join the routines in a lisp, I just need to include the function to check the nam e of the block before copying it to the OD, I share the .lsp regards!ADDID_OD2ATT.lsp

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