Hi All,
this is my first post, so far I haven't need to ask anything because you have asked all the questions that I had
I've created a custom palette with the user control, I'm putting the block with attributes in the drawing. I have about 100 different values for attributes, they are all sorted in 6 comboboxe's. The code is a classic while loop build around the GetPoint.
public void insBlok(string code)
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Utils.SetFocusToDwgView();
Point3d ptPoint = new Point3d(0, 0, 0);
try
{
while (ptPoint != null)
{
PromptPointResult pPtRes;
PromptPointOptions pPtOpts = new PromptPointOptions("");
pPtOpts.AllowNone = true;
pPtOpts.Message = "\nSelect point: ";
pPtRes = doc.Editor.GetPoint(pPtOpts);
if (pPtRes.Status == PromptStatus.None || pPtRes.Status == PromptStatus.Cancel || pPtRes.Status == PromptStatus.Error)
{
return;
}
ptPoint = pPtRes.Value;
using (DocumentLock loc = doc.LockDocument())
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
...................
using (BlockReference blockRef = new BlockReference(ptPoint, btr.ObjectId))
{
foreach (ObjectId id in btr)
{
//insert value in attribute,
}
}
tr.Commit();
}
}
}
}
catch (System.Exception x)
{
ed.WriteMessage("\nError: " + x.Message);
}
finally
{
ed.WriteMessage("\n");
}
}
This is a code for button click:
private void cboBtn_ButtonClick(object sender, EventArgs e)
{
string buttonText = ((ComboBox1)sender).Text;
buttonText = buttonText.Substring(0, 3);
insBlok(buttonText);
}
When I click on the button, ewerything work as sholud, but when I select different attribut from ComboBox and click again on the button
(without ending first command with Enter or Esc), same command fire's once again, this time nested in previous transaction. After ending second command, first command is active.
I could create
bool active_command, but there is another User Form with similar code (different block with different attribute values), so I am able to change palette, select attribute value, click on button on that User Form, insert that block, and after that first command is active.
Command is without
CommandMethod atribut, it can be called only from custom palette.
What now? I can remove whilw loop, but then user must click every time on the button. With CommandMethod atribute i should have 100 commands (this is addin not only for Autocad). SendCommand ^C^C is not an option, I think.....