AnsweredAssumed Answered

Insertion point MakeSketchBlockFromSelected

Question asked by Todd Carpenter on May 3, 2018
Latest reply on May 3, 2018 by Simon Turner

Hi All,

 

I'm having an issue controlling where my insertion point is located when I create a block using the API.  When I use the API, the point is always center of the height of the geometry, and way to the right.  I've inserted the drawing geometry at 0,0 when I import it, and I tried supplying an insertion point of 0,0 but it doesn't seem to change anything.  Here's the code I'm using, (the important parts anyway), nothing fancy:

 

SelectionMgr swSelMgr;


swSelMgr = (SelectionMgr)swModel.SelectionManager;
swModelDocExt.SelectAll();


// Write the block out.


MathUtility swMathUtil = swApp.IGetMathUtility();
MathPoint swMathPoint;


double[] nPt = new double[3] { 0.0, 0.0, 0.0 };


Object vPt = nPt;


swMathPoint = (MathPoint)swMathUtil.CreatePoint(vPt);


SketchBlockDefinition swBlockDefinition = null;
swBlockDefinition = ((SketchBlockDefinition)(swModel.SketchManager.MakeSketchBlockFromSelected(swMathPoint)));


string blockFileName = sDwgFileName.Replace(".dwg", ".sldblk");


swBlockDefinition.Save(blockFileName);
swModel.EditDelete();

 

Am I doing something wrong?  When I create the block by hand, the insertion point is always the lower left corner of the geometry bounding box - I initially thought that would be the default behavior in the API as well - I was obviously wrong.

 

Any help would be appreciated - thanks!

Outcomes