How to Display Block Library (DWG file) in the Blocks Palette Using AutoLISP

_Bilal
Advocate
Advocate

How to Display Block Library (DWG file) in the Blocks Palette Using AutoLISP

_Bilal
Advocate
Advocate

 

Hello,

 

I need help with creating an AutoLISP routine that display a specified block library (DWG file) in the Blocks palette, similar to the screenshot below. Let say the file name is (setq filename "c:\\path\\...........\\libraryfile.dwg"), how to display the filename in the block palette?

 

_Bilal_0-1718838762274.png

 

Thank you in advance for your help!

 

0 Likes
Reply
548 Views
8 Replies
Replies (8)

krazeymike
Enthusiast
Enthusiast

Not sure if I can answer your question but I use the Design Center "ADCENTER" that points to our Template / Drawing Files. You can Shift Click All, right click and add blocks to your existing drawing. You can do the same for Line styles, Text Styles and Layers etc.
Then you can use the "Current Tab" or the Tool Palette when inserting Blocks 😁

0 Likes

_Bilal
Advocate
Advocate

Thank you for your response! Using the Design Center and Tool Palette is definitely useful for many scenarios. However, I am specifically looking to automate the process of displaying a block library (DWG file) directly in the Blocks Palette using AutoLISP.

Passing the filename as argument and attempts to open the Blocks Palette. The missing part I am looking for is how to link this file directly to the Blocks Palette.

 

(defun OpenBlockLibrary ( "C:\\path\\to\\your\\libraryfile.dwg" / )


          ;; Need to add code to show 'libraryfile.dwg' in the Blocks Palette
)

0 Likes

Kent1Cooper
Consultant
Consultant

I suspect the only way to do that would be to INSERT your LibraryFile drawing into the current drawing, then ERASE what you just Inserted.  Then all its Block definitions will be in the current drawing, so the Blocks Palette can show them, and the drawing name will also be in there as a Block name.  But that means carrying all those definitions in the drawing, however few of them you actually use, increasing the file size.  That INSERT/ERASE could easily be automated.

Kent Cooper, AIA
0 Likes

daniel_cadext
Advisor
Advisor

You should be able to do this with OpenDCL

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes

Sea-Haven
Mentor
Mentor

This is old fashioned Pop menu, yes could add behind the scenes file name. The word PITS is under your control its just a label. The pop menu supports more than 16 images it has an auto Next/Prev.

SeaHaven_0-1719103347890.png

 

 

0 Likes

john.uhden
Mentor
Mentor

@Sea-Haven ,

Are those images slide files or something better?

I had a routine in the 90s for creating and accessing our company's library of standard details.  The only way I knew of creating the images was via slides, but at least every user could access and add to the library.

John F. Uhden

0 Likes

Sea-Haven
Mentor
Mentor

Yes they are slides as that is what pop menu uses. But behind the scenes is SLB's that contains common groups of slides so reduced number of files.

 

You can make a dwg full of blocks to slides very fast, just using a lisp. See image in 1st post based on a dwg.

0 Likes

king
Enthusiast
Enthusiast

This is the workaround i was able to come up with.

in my tool palettes i have this for the "command string" 

(load "Z:/_TEMPLATES/CAD Templates/_LISP/_Deployed/_DETAILLIBRARY - InsertDetailFiles.lsp");INSERT_BRICK_VENEER


that .lsp file contains:

(defun c:INSERT_BRICK_VENEER ()
  (setq FILE_PATH "Z:\\_TEMPLATES\\CAD Templates\\_Detail Library\\BRICK VENEER.dwg")
  (command "INSERT" FILE_PATH (list 0.0 0.0 0.0) "1" "1" "0")
  (princ)
)
 
 
This allows me to insert any of the dozens of template file we have into the current drawing
0 Likes