Copy all block references with a given name into the current dwg using ObjectDBX

Copy all block references with a given name into the current dwg using ObjectDBX

Kh.mbkh
Advocate Advocate
663 Views
8 Replies
Message 1 of 9

Copy all block references with a given name into the current dwg using ObjectDBX

Kh.mbkh
Advocate
Advocate

Is it possible to access a set of dwg files, copy all block references on it that match a given name, and past into current dwg with original coordinates ? ( I am not sure if ObjectDBX can do it ... )

0 Likes
Accepted solutions (1)
664 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor

give attached copytocurrentdwg.lsp a try

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 9

komondormrex
Mentor
Mentor

what is the  set of dwg files?

0 Likes
Message 4 of 9

Kh.mbkh
Advocate
Advocate
Great 👍, one more question please, is it possible to access the dwg file even if it is already opened on Acad ?
(Sometimes we want to copy blocks in all open files on Acad editor into the active document)
Thanks.
0 Likes
Message 5 of 9

paullimapa
Mentor
Mentor
Accepted solution

I don't believe you can access a currently opened drawing. The obvious danger for this is that as another user is working on it there may have been updates in this case to the block you're wanting to copy and a save has not been performed. Then you would end up copying a block that is not up-to-date.

But if you don't care, then a way around this would be to copy the locked drawing to temp location and access the dwg in that temp location to grab your block.

@Kh.mbkh try CopyToCurrentDwgT.lsp


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 9

Sea-Haven
Mentor
Mentor

Did you look at Lee-mac Steal lisp it allows you to simply get a block from another dwg, and can be ran without user input.

Message 7 of 9

Kh.mbkh
Advocate
Advocate
Thanks Paul, perfect solution !
Please, Where can I find the full documentation of ObjectDBX for AutoCAD ?
For E.g, (vla-open (list odbx copydoc)) - (vla-get-blocks oDBX) ... Where to find all method, propreties to apply for that oDBX ...
Searching on Autodesk website does not give much:
https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-FF60A11B-1169-483C-9A65-85203B3A1440

Thanks again !
0 Likes
Message 8 of 9

paullimapa
Mentor
Mentor

Well it's basically accessing the object whether it's the current active dwg:

(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

or in this case the database of another dwg:

     (setq oDBX
      (vl-catch-all-apply 'vla-getinterfaceobject
       (list (vlax-get-acad-object)
        (if (< (setq oVer (atoi (getvar 'acadver))) 16)
           "objectdbx.axdbdocument"
           (strcat "objectdbx.axdbdocument." (itoa oVer))
        )
       )
      )
     )

I'd refer you to this site:

GitHub - Fraiddd/ODBX_LIB: Batch processing dwg with ODBX in Autolisp / Visual Lisp for Autocad


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 9

Kh.mbkh
Advocate
Advocate
Lee-mac Steal lisp import a block DEFINITION from another dwg, but not block REFERENCES.
0 Likes