Here is a sample of how to use what I posted yesterday:
#include "AcadUtilities.h"
void foo() {
AcadUtilities acadUtils(curDoc()->database());
// Import a layer
// importLayer searches through the file specified by the LAYERS_FILE constant
// until it finds a layer name that matches the argument. Then uses
// the data in the layers file to create the layer in the current dwg.
// Layers file format is LayerName,Color,Linetype
if(!acadUtils.importLayer("MyLayer")) {
acutPrintf("\nUnable to import layer: MyLayer");
acutPrintf("\nAborting!");
return;
}
// Import a block definition
// First argument is file name. Second is the name to give the block
AcDbObjectId blockObjId = acadUtils.importBlock("MyBlock.dwg", "MyBlock");
if(!blockObjId) {
acutPrintf("\nUnable to import block: MyBlock.dwg");
acutPrintf("\nAborting!");
return;
}
// Insert an instance of the block
// Arguments are
// ObjectId of block table record,
// Insertion point,
// Scale,
// Rotation,
// Layer to insert onto
acadUtils.insertBlock(blockObjId,
AcGePoint3d(0, 0, 0),
AcGeScale3d(1, 1, 1),
0,
"MyLayer");
// Draw a line
// Start point,
// End point,
// Layer
acadUtils.addLine(AcGePoint3d(0, 0, 0),
AcGePoint3d(1, 1, 0),
"MyLayer");
// Draw a box
// Lower left corner,
// Upper right corner,
// Layer
acadUtils.addRectangle(AcGePoint3d(0, 0, 0),
AcGePoint3d(1, 1, 0),
"MyLayer");
// Draw text
// Insertion,
// Height,
// Rotation,
// Horizontal alignment,
// Vertical alignment,
// Text string,
// Layer
acadUtils.addText(AcGePoint3d(0, 0, 0),
0.09375,
0,
AcDb::kTextMid,
AcDb::kTextVertMid,
"SAMPLE TEXT",
"MyLayer");
}
[edit]formatting went a little wonky[/edit]