The conversion – degrees to radians – is being done internally. Note that the InsertBlock method here is used with a small variation: the RotationAngle must be given in degrees. The code is actually a loop most of the code is used to initialize the AutoCAD object, as well as the active/new drawing. VBA code for adding blocks in AutoCAD from Excel
Then, by clicking the “Insert Blocks” button the blocks are inserted either in the active drawing (if AutoCAD is already launched), or in a newly created drawing. Optional parameters are the scale factors (in X, Y, and Z axes) as well as the rotation angle.
The sample workbook that you will find in the Downloads section below requires two main and two optional parameters: the coordinates of the insertion point (in X, Y, Z) and the block name (or its full path, including the.
The rotation angle relative to the WCS X-axis expressed in radians. RotationAngle: Double input-only (optional). dwg extension and any path information necessary for AutoCAD to find the file. The name of the AutoCAD drawing file or the name of the block to insert. The 3D WCS coordinates specifying the location in the drawing to insert the block.īlockName: String input-only. InsertionPoint: Variant (three-element array of doubles) input-only. Object: ModelSpace Collection, PaperSpace Collection, Block – the objects this method applies to. The placed block as a Block Reference object. RetVal = object.InsertBlock(InsertionPoint, BlockName, Xscale, Yscale, Zscale, RotationAngle) Anyway, according to AutoCAD VBA help, the structure of InsertBlock method is the following: The code presented today is not new it was written actually some months ago (in April). I gave him some insight and I think that it’s time to present the complete solution, which involves AutoCAD’s InsertBlock method. In the comments section of the previous post about AutoCAD and Excel interaction, a blog reader (Tim) asked me if it is possible to insert blocks in AutoCAD from Excel.