thanks for the reply to both of you.
Giles, I modified your code because I didnt want the basepoint option. now I have a problem:
I cant see the block ref moving with my cursor. its only at (0,0,0).
what Im I doing wrong?
class DragEntitiesJig : DrawJig
{
Point3d dragPoint;
IEnumerable<Entity> ents;
public DragEntitiesJig(IEnumerable<Entity> ents)
{
this.ents = ents;
}
protected override bool WorldDraw(WorldDraw draw)
{
WorldGeometry wGeom = draw.Geometry;
foreach (Entity ent in this.ents)
{
wGeom.Draw(ent);
}
wGeom.PopModelTransform();
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
var options = new JigPromptPointOptions();
options.UserInputControls = (UserInputControls.Accept3dCoordinates);
var result = prompts.AcquirePoint(options);
if (dragPoint.IsEqualTo(result.Value))
return SamplerStatus.NoChange;
else
dragPoint = result.Value;
return SamplerStatus.OK;
}
}
and this is my test method:
public class JigTest
{
[CommandMethod("test")]
public void Test()
{
var doc = acap.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
var db = doc.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
var blkTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
var blk1 = new ObjectId();
var blk2 = new ObjectId();
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
blk1 = blkTable["1"];
blk2 = blkTable["2"];
var blkref1 = new BlockReference(Point3d.Origin, blk1);
var blkref2 = new BlockReference(Point3d.Origin, blk2);
var blkList = new List<Entity>()
{
blkref1,
blkref2
};
var jig = new DragEntitiesJig(blkList);
var jigResult = ed.Drag(jig);
if (jigResult.Status == PromptStatus.OK)
{
curSpace.AppendEntity(blkref1);
tr.AddNewlyCreatedDBObject(blkref1, true);
curSpace.AppendEntity(blkref2);
tr.AddNewlyCreatedDBObject(blkref2, true);
}
tr.Commit();
}
}
}
also can you tell me how to modify the class driven from EntityJig to get multiple entities? can I remove :base(br) in the line :
public JigBlockReference(BlockReference br)
: base(br)
public class JigBlockReference : EntityJig
{
protected Point3d dragPoint;
protected BlockReference br;
public JigBlockReference(BlockReference br)
: base(br)
{
this.br = br;
dragPoint = br.Position;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
var options = new JigPromptPointOptions(
"\nSpecify destination point or rotate 90° [Left/Right]: ", "Left Right");
options.UserInputControls = (UserInputControls.GovernedByOrthoMode);
var result = prompts.AcquirePoint(options);
if (dragPoint.IsEqualTo(result.Value))
return SamplerStatus.NoChange;
else
dragPoint = result.Value;
return SamplerStatus.OK;
}
protected override bool Update()
{
br.Position = dragPoint;
return true;
}
}