What is the everyone's thought on the best practice for block insertion. Specifically, would you put the blocks to be inserted inside the template file? Would you store it in a offline file and copy it into the file when it is needed? Or would you create the block when needed thru programming? I would like to stay away from the last option as it not lend itself to changing blocks easily. Any thoughts on the subject would be appreciated. Thanks.
there will not be ONE answer that is correct and the others are not. It depends on what your application needs, how you update works for your customers, what workflows your app is running with symbology.
But of course, there are some thoughts when I beginn some app to develop and most of them will be around how do I update symbols at customer site without distroying customization they (customer) did in the meantime.
As a thought about "all block in a template" ==> what will happen when your customer modifies some blockdefinitions (or other styles, layers, sysvars, ...) within your application-template ==> you can't replace his template with a new one from your application version 2.
Similar situation when you have all your blockdefinitions in one drawing from where you wblockclone the blockdefinitions into the current working drawing. But in this case you can add a mechanism into your app that allows the user to create in a separate drawing with the same blockname like in your symbol-drawing. Your app can then first look in the customer drawing if a block with a specific name exists, if yes take the customized blockdef, if not take the block from your global application symbol-DWG.
If you have each block as a single DWG-file (organized within a directory or an app-specific directory-structure) you can use a similar structure like in a symbol-DWG, if the user has a DWG-file with the same name in his "custom"-directory take it, if not insert the DWG from your application-folder(s).
To have single DWG-files has the advantage to simply copy one DWG-file if you just need to update one symbol. But you have the disadvantage if there are layers within the symbols used and you need to change the layer-properties or -names you have to redefine each of the DWG-files. If you have one symbols-DWG you have just to open it, modify the layers and save the drawing.
My 2c, there will come more, I'm sure
1) My program does draw about 90% (to hazard a guess) of the blocks it needs from code, based on dimensional information and other various options either selected by the user, or calculated by the program. These are all 3D blocks, and there are so many options involved that a block library would be prohibitively large and difficult to maintain. (The original version of my code, was LSP, in 2002, and used a block library. The old library has about 5000 blocks in it, but all the possible variations were never created, and the options have expanded since then, so again, to hazard a guess, my program is capable of creating in the neighborhood of 100,000 distinct blocks, if all the options are used).
2) That said, I mentioned these are 3D blocks, and some of the pieces that make up a block are complicated shapes that would be extremely tedious to draw in code, so I create those pieces in what I call a "Seed" file (offline file, in your post), and my code WblockClones them into the current drawing when it needs to, and inserts them into the parent Block definition at the right location, as it creates the parent block. At this time, there are about 80 blocks in my seed file. There used to be more, but I found the need to make some of the assemblies dimensionally flexible, so I broke them down into smaller pieces and made the code to put the pieces together with the currently selected dimensional info.
3) Just to make things as robust as possible (and I do have some code that is not for my specialized design program, but rather just for basic cad tasks like inserting 2D symbol blocks, or annotations) I have one InsertBlock Routine in my .NET code, that will find and retrieve the block from: 1- Inside the Current Drawing, 2-Inside the Seed DWG, 3-In AutoCAD's Search Path, 4-In any searchable drive on the users computer, including mapped network drives.
4) Finally, I would summarize by saying, in my opinion, of the options listed in your question, the only one I would suggest avoiding is keeping them in the template file. This makes the template file large (larger than it needs to be), and then you have to worry about the user purging a drawing, then running your code which requires a block that has been purged.
PS. For some (2D only) blocks, I have written some code which is an expansion of this Kean Walmsley Post, His post only handles code for one type of entity selection, and one type of entity output, but it demonstrates a technique (not rocket science, at all) to allow you to select entities in a drawing window, and put C# (or in my case VB) code on your clipboard to re-create each of the entities selected. This makes the coding for simpler objects much easier, even if you need to modify the code afterwards to make it respond to a dimensional variable instead of being a fixed dimension, for instance.
That approach obviously won't work for 3D Solids, because you can't get enough information from AutoCAD about the existing solid to recreate it.
Edit: Just to be clear, I don't need to worry about "Customer's" wanting to change things, because all my work is currently for use by my company only, and not for sale.
Thank you both for the suggestions. What I need to do is really quiete simple. I need to place a block on the end of a pipe. The block will be 2D and will have to be chosen from only 7 blocks. The context of what I am doing is we are using pipeobjects for threaded rods for trapeze and clevis hangers. I want to place a 2D block on the end of the threaded rod that will match up to the size of the rod. 7 rod sizes, 7 blocks. We we then export those blocks to a seperate cad drawing to be used by the field in a Trimble unit.
So I plan on cycling through all of the pipes in the drawing. If it is a threaded rod, get the pipe size. Once the pipe size is known, choose the appropriate block. Compare the start and end coordinates of the pipe and which ever is at a higher Z elevation use that set of coordinates as the insertion point of the block. At this point, the program is solely for company use. But management is constantly changing their minds on what things should look like so I foresee the blocks changing more than once. My idea was to have a tab on the options page that would facilitate chosing blocks for pipe sizes. Make sense? Any thoughts either positive or negative on this process? This will be my first programming assignment using .net in autocad. I don't think it is that difficult of a programming assignment but I would like to do it correctly the first time. I am also new to the .net programming language.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register