Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am able to rotate the Block but I want the reference line to be shown when I am rotating same as it is shown During Rotate command.
Attached video I run my command and for second I use the rotate command.
[CommandMethod("TestRotation")]
public static void TestEntityJigger5_Method()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptEntityResult selRes = ed.GetEntity("Pick a block:");
if (selRes.Status == PromptStatus.OK)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference ent = tr.GetObject(selRes.ObjectId, OpenMode.ForWrite) as BlockReference;
if (ent != null)
{
using (Transaction tr1 = db.TransactionManager.StartTransaction())
{
ent.Highlight();
tr1.Commit();
}
if (BlockRotating.Jig(ent))
tr.Commit();
else
tr.Abort();
}
}
}
}
public class BlockRotating : EntityJig
{
#region Fields
public int mCurJigFactorNumber = 1;
private double mRotation = 0.0; // Factor #1
#endregion
#region Constructors
public BlockRotating(Entity ent)
: base(ent)
{
}
#endregion
#region Overrides
protected override bool Update()
{
switch (mCurJigFactorNumber)
{
case 1:
(Entity as BlockReference).Rotation = mRotation;
break;
default:
return false;
}
return true;
}
protected override SamplerStatus Sampler(JigPrompts prompts)
{
switch (mCurJigFactorNumber)
{
case 1:
JigPromptAngleOptions prOptions1 = new JigPromptAngleOptions("\nBlock rotation angle:");
prOptions1.BasePoint = (Entity as BlockReference).Position;
prOptions1.UseBasePoint = true;
PromptDoubleResult prResult1 = prompts.AcquireAngle(prOptions1);
if (prResult1.Status == PromptStatus.Cancel) return SamplerStatus.Cancel;
if (prResult1.Value.Equals(mRotation))
{
return SamplerStatus.NoChange;
}
else
{
mRotation = prResult1.Value;
return SamplerStatus.OK;
}
default:
break;
}
return SamplerStatus.OK;
}
#endregion
#region Method to Call
public static bool Jig(BlockReference ent)
{
try
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
BlockRotating jigger = new BlockRotating(ent);
PromptResult pr;
do
{
pr = ed.Drag(jigger);
jigger.mCurJigFactorNumber++;
} while (pr.Status != PromptStatus.Cancel &&
pr.Status != PromptStatus.Error &&
pr.Status != PromptStatus.Keyword &&
jigger.mCurJigFactorNumber <= 1);
return pr.Status == PromptStatus.OK;
}
catch
{
return false;
}
}
#endregion
}
What I am Expecting
Solved! Go to Solution.