0
試圖運行從雙擊後命令行ATTEDIT並將其選擇以前選定的項目。我截獲了雙擊事件並且可以運行ATTEDIT,但是當我嘗試將位置傳遞給「ATTEDIT選擇一個塊:」時,它什麼也不做。但是當我再次點擊該塊時會起作用。我以爲這是因爲我的單位是十進制單位而不是建築單位。但是這並不如此。以下是我有:在鼠標工作的architectual位置的AutoCAD .SendStringToExicute ATTEDIT不選擇選擇的對象
using Autodesk.AutoCAD;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class DoubleClickProcess
{
// This function gets called when a block reference is double clicked on. It then checks to see if the block reference
// that was double clicked on was double clicked
[CommandMethod("DOUBLECLICK", CommandFlags.UsePickSet)]
public void ContinueDoubleClick()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database database = HostApplicationServices.WorkingDatabase;
Editor ed = doc.Editor;
// Get the PickFirst selection set
PromptSelectionResult acSSPrompt;
acSSPrompt = ed.SelectImplied();
SelectionSet selRes;
// If the prompt status is OK, objects were selected before
// the command was started
if (acSSPrompt.Status == PromptStatus.OK)
{
selRes = acSSPrompt.Value;
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
// Go through all of the objects that were selected...
ObjectId[] objIds = selRes.GetObjectIds();
foreach (ObjectId objId in objIds)
{
Entity theEnt = (Entity)tr.GetObject(objId, OpenMode.ForRead);
// They must be block references...
if (theEnt.GetType().Name.ToUpper() == "BLOCKREFERENCE")
{
BlockReference bRef = theEnt as BlockReference;
BlockTableRecord btr = null;
btr = tr.GetObject(bRef.DynamicBlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
if (bRef != null)
{
// If it is a specific block then we are interested in it
if (btr.Name.ToString().ToUpper() == "specific")
{
doc.SendStringToExecute("SomeCommand ", true, false, true);
}
else
{
// It's not one we're interested in so do what double clicking would normally do
String objPx = Autodesk.AutoCAD.Runtime.Converter.DistanceToString(bRef.Position.X);
objPx = objPx.Replace(" ", "-");
String objPy = Autodesk.AutoCAD.Runtime.Converter.DistanceToString(bRef.Position.Y);
objPy = objPy.Replace(" ", "-");
String objP = objPx +","+ objPy;
doc.SendStringToExecute("ATTEDIT "+ objP + " ", true, false, true);
}
}
}
theEnt.Dispose();
}
tr.Commit();
}
}
// Clear the PickFirst selection set
ObjectId[] idarrayEmpty = new ObjectId[0];
ed.SetImpliedSelection(idarrayEmpty);
}
}
}
打字(101'-6-7/8" ,89'-5-1/2" ),但如果你鍵入的實際該塊的位置不會選擇塊屬性。
似乎並沒有工作。 selset值顯示爲:{((((8796087858048),Unavailable,0,))}但我認爲它應該是這樣的:{((((8796087858048),PickPoint,1,))}。你會知道如何獲得PickPoint和那裏的1嗎? – Corey
有沒有其他建議? – Corey