Transfer Link Template Data to Object Data

Transfer Link Template Data to Object Data

BriamR
Advocate Advocate
890 Views
5 Replies
Message 1 of 6

Transfer Link Template Data to Object Data

BriamR
Advocate
Advocate

Hello Community! I have been researching this for some time, I am trying to know if it is possible through a routine (lisp) to transfer / copy the information from LT (link template associated with a database in access) to the OD (object data) as I show in the image.

 

image.png.fe23aaf1f9aacedca588a0e3e25a109d.png

image.thumb.png.b988533bc6583bb0cd810fc454e9b7ef.png

So i need a very specific Lisp/VLisp/VBA/Dotnet routine who asks for :

-- The Link Template DB name

-- Which DB fields are you interested for

-- Which OD Table MAP to fill

-- Which OD Fields MAP to create or to use (if already existing)

-- Selecting objects

-- Retain only objects which the correct parameters

-- ACTION ... Copy Data to OD fields ...


append DWG & MDB files as example

I carry this topic in this autodesk post https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-that-copies-link-template-to-ob...

 

thanks for the help you can give me, greetings.

891 Views
5 Replies
Replies (5)
Message 2 of 6

BriamR
Advocate
Advocate

Community, I have been researching on the subject, I found this support material


1. ADOLisp .
2. MS-Access-and-Object-data 

3. ms-access-to-attributes


I appreciate your help on this project.

Message 3 of 6

BriamR
Advocate
Advocate

ADOlisp seems to be a good sign for this project, I'll let you know if I get anything done, I'm open to any suggestions or help regarding the release. Thanks!

Message 4 of 6

hosneyalaa
Advisor
Advisor

Hi @BriamR 

I not used it before and I don't know how to use it,  you have a video look

But I looked at it a little

 But you have one KeyValues Can two KeyValues I mean the first and second fields KeyValues

0 Likes
Message 5 of 6

BriamR
Advocate
Advocate
Hi @hosneyalaa
The keyvalues is only one in the DB and in the LT, for each table the keyvalues is INTERNO_DEMARCACION and INTERNO_SENAL. thanks for your interest in the publication
0 Likes
Message 6 of 6

BriamR
Advocate
Advocate

I have been working with this code to solve the issue of copying the LT in the OD; it generates the following ; error: bad argument type: lentityp (0 <Entity name: 1f248ae1f30> 3)

(defun c:LT_OD (/ dwg ss sdm-dem-demarcacion sdm-dem-inter-demarcacion sdm-dem-clase-demarcacion link-template link-template-field db-file db-table db-field db-clase-field conn rs int-dem clase-dem)
  (setq dwg (vlax-get-acad-object))
  (setq ss (ssget))
  (setq sdm-dem-demarcacion "SDM_DEM_DEMARCACION")
  (setq sdm-dem-inter-demarcacion "INTERNO_DEMARCACION")
  (setq sdm-dem-clase-demarcacion "CLASE_DEMARCACION")
  (setq link-template "SDM_DEM_DEMARCACION")
  (setq link-template-field "INTERNO_DEMARCACION")
  (setq db-file (strcat (getvar 'dwgprefix) "SIGMOVILIDAD_2012.mdb"))
  (setq db-table "DEM_DEMARCACION")
  (setq db-field "INTERNO_DEMARCACION")
  (setq db-clase-field "CLASE_DEMARCACION")
  (setq conn (vl-catch-all-apply 'vla-get-activedocument (list dwg)))
  (setq rs (vl-catch-all-apply 'vlax-create-object (list "ADODB.Recordset")))
  (foreach obj (vl-remove-if-not 'vla-object->ename (mapcar 'vlax-ename->vla-object (ssnamex ss)))
    (if obj
      (progn
        (setq int-dem (vla-putproperty obj link-template link-template-field))
        (vl-catch-all-apply 'vlax-invoke-method rs "Open" (list (strcat "SELECT * FROM " db-table " WHERE " db-field "=" int-dem) conn))
        (if (not (vlax-invoke-method rs "EOF"))
          (progn
            (setq clase-dem (vlax-invoke-method (vlax-get-property rs "Fields") db-clase-field "Value"))
            (vla-putproperty obj sdm-dem-demarcacion sdm-dem-inter-demarcacion int-dem)
            (vla-putcustomstringdata obj sdm-dem-demarcacion sdm-dem-clase-demarcacion clase-dem)
          )
        )
        (vlax-invoke-method rs "Close")
      )
    )
  )
  (princ)
  (princ "Valores de campos copiados con éxito a Object Data.")
  (princ)
  (prin1)
)

I am still trying to get the expected result, any ideas?

0 Likes