I gave up on Tool Palettes a loooong time ago.
If there was a method for using a lisp routine for inserting a block reference from another drawing (instead of inserting a drawing as a block itself) that would work wonders as well.
Yes, there is. Take a look at the following:
(defun jb:InsertSymbol(lkey dname / *Error*)
(defun *Error* (Msg)
(cond ((or (not Msg)
(member Msg '("console break"
"Function cancelled"
"quit / exit abort"))))
((princ (strcat "\nError: " Msg))))
(jb:ResetActiveSymbolLayer)
(princ))
(cond((= lkey "Appliances")
(jb:SetActiveSymbolLayer "APPL"))
((= lkey "Furniture")
(jb:SetActiveSymbolLayer "FURN"))
((= lkey "Lighting")
(jb:SetActiveSymbolLayer "LIGHTCLG"))
((= lkey "Power")
(jb:SetActiveSymbolLayer "POWER"))
((= lkey "HVAC")
(jb:SetActiveSymbolLayer "EQUIPCLG"))
((= lkey "Plumbing")
(jb:SetActiveSymbolLayer "PFIXT"))
((= lkey "Fire")
(jb:SetActiveSymbolLayer "FIRE"))
((= lkey "Equipment")
(jb:SetActiveSymbolLayer "EQUIP"))
(t (jb:SetActiveSymbolLayer "EQUIP"))
)
(if (not (tblsearch "block" dname))
(jb:ImportBlock (jb:ReturnProjectAECStylesStandardsFile) dname))
(command "_.insert" dname "_scale" 1 pause "0")
(jb:ResetActiveSymbolLayer)
(princ)
)
I use this to insert dynamic symbol blocks, i.e. electrical, appliances, tags, etc. Here is a breakdown of whats going on:
(jb:SetActiveSymbolLayer "APPL") saves the current layer name, creates and sets current the layer associated with the layerkey "APPL".
(jb:ImportBlock (jb:ReturnProjectAECStylesStandardsFile) dname) if the block doesn't exist in the current drawing, this imports it from the Project Standards file.
(jb:ResetActiveSymbolLayer) resets the current layer saved by jb:SetActiveSymbolLayer.
The layerkey sub routines utilize tools exposed by AecLMgrLisp.arx. The import sub routine utilizes ObjectDBX.