Force block insertion from block definition within another drawing file

Force block insertion from block definition within another drawing file

mspeace
Enthusiast Enthusiast
229 Views
3 Replies
Message 1 of 4

Force block insertion from block definition within another drawing file

mspeace
Enthusiast
Enthusiast

Hello all,

 

I have a lisp from way back that I am trying to bring current with some necessary changes. 

 

I am trying to update my old lisp to utilize block definitions that are contained in a single .DWG. My old company had a library of individual .DWGs of each block so "-insert" worked fine. 

 

My new company has a single .DWG that contains all of their blocks. 

 

I'm trying to force an insert of the block from the library drawing regardless of if the block already exists in the current drawing, and even if its already been inserted and currently in use. 

 

It looks like its very depended on whether or not the block contained in the library drawing has been updated or not, or differs form the one already defined in the current drawing. 

 

I want to simply insert the block from the library drawing regardless. That way if its changed, it gets redefined, if it hasn't changed, it probably will still get redefined, but I don't care. I always want what is in the library drawing to be used.

 

I have attached the lisp I have currently but its just not doing all the necessary checks and conditionally inserting the block. I would appreciate a fresh set of eyes that may have a different approach to my logic.  

0 Likes
230 Views
3 Replies
Replies (3)
Message 2 of 4

cadffm
Consultant
Consultant

Hi 

use a large complicated code way via API,

or use a translater abd read this post and following, incl. the last picture:

 

 

https://ww3.cad.de/foren/ubb/Forum145/HTMLna/005002.shtml#000012

 

 

Sebastian

0 Likes
Message 3 of 4

paullimapa
Mentor
Mentor

Could you also share the dwg the lisp references:

C:\\RICK_C3D\\C3D_RICK_NCS_2022\\Resources\\DEN\\DEN_GENERAL.dwg

But just taking a quick look at the routine it seems to check for the existence of the block definition in the current drawing and includes code to handle one way vs another for inserting the following 2 blocks:

"ARV_RICK_LOGO_EXHIBIT_COLOR"

"DEN-ARRW_2_COLOR"

   (if(tblsearch "block" "ARV_RICK_LOGO_EXHIBIT_COLOR")
           (command "-INSERTCONTENT" "C:\\RICK_C3D\\C3D_RICK_NCS_2022\\Resources\\DEN\\DEN_GENERAL.dwg" "ARV_RICK_LOGO_EXHIBIT_COLOR" "Y" "7.5995,0.475,0" "" "" "")
           (command "-INSERTCONTENT" "C:\\RICK_C3D\\C3D_RICK_NCS_2022\\Resources\\DEN\\DEN_GENERAL.dwg" "ARV_RICK_LOGO_EXHIBIT_COLOR" "7.5995,0.475,0" "" "" "")
     );END IF
   (if(tblsearch"block""DEN-ARRW_2_COLOR")
          (command "-INSERTCONTENT" "C:\\RICK_C3D\\C3D_RICK_NCS_2022\\Resources\\DEN\\DEN_GENERAL.dwg" "DEN-ARRW_2_COLOR" "Y" (getvar "viewctr") "" "" vtwst)
          (command "-INSERTCONTENT" "C:\\RICK_C3D\\C3D_RICK_NCS_2022\\Resources\\DEN\\DEN_GENERAL.dwg" "DEN-ARRW_2_COLOR" (getvar "viewctr") "" "" vtwst)
     );END IF

Exactly what is not working?


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

cadffm
Consultant
Consultant

Hi,

@mspeace 

1. Set cmdecho to 1 (in your code) to check where it goes wrong.

2. Run tests ONLY in new opened files!

    (Because your code does work only once in your file session, this is what I talked  about in the linked german thread)

 

 

Sebastian

0 Likes