PDA

View Full Version : How can I put a block on a tool palette with code?



neeboy74
2024-10-18, 01:21 AM
I really, really need the ability to build tool palettes full of blocks by coding. Yes, I need to do it this way, I have to constantly re-make close to 50 tool palettes every 3 weeks or so. It is an extremely arduous task, and very soon, I will have to make close to ONE HUNDRED tool palettes. No, we can't make them "networked" either, they have to be distributed externally to our customers who use our blocks.



One of the major driving forces behind this request is we need the ability to mix-and-match blocks from various releases, such as Rev 11-1 of Block #50 at the same time as Rev 10-3 of Block #50 and so on. So the name of the block in the resource dwg may not change...execept for the rev number in that block name. Overall, this may not sound like a good idea, but it is the setup I have to operate in. Reasoning/rationale for it is too much to elaborate on in this initial post, trust me.



I have done an absolute TON of searching over the last week. I keep finding "put commands" or "put buttons" on a tool palette with code. I MUST have the coding ability to put a BLOCK on a tool palette, and then set Tool Properties with code also.



I cannot build an XML/write an atc file from scratch to make a tool palette like that, I have tried that, and the code is waaaaay too much to try and decipher/reverse engineer; that is NOT an option.



Is what I want possible within the API with any officially defined Methods? I myself am not an experience coder, but I have several coworkers who are, so if you have applicable fragements of knowledge, I'm all ears. This would change my whole world unbelievably

Opie
2024-10-18, 03:17 PM
XML is a text based file. Creating the necessary elements are not difficult to create through programming. It is understanding the necessary information that is needed. Building a tool palette programmatically is not the recommended method. I'm not even sure there are methods available as I don't use .NET often.

I would recommend you take several existing palettes and evaluate the differences. Once you understand the differences, you could develop differing sub-routines to compile a new tool palette. You would have sub-routines to generate the headers/footers of the file and other sub-routines to build the tool sections.

You could also create snippets of working tools to combine with a new tool palette.

Each tool in the palette must have a unique GUID along with other required properties.

There is an associated Catalog (.ATC) file containing links to each tool palette you will need to analyze before getting it all working correctly. It is typically located in the parent folder of the folder containing the tool palette .ATC files.