- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
Kindly suggest on it.
I have drawn a Polyline using below statement:
Acad.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("PL ", true, false, true);
Got polyline object as below:
ObjectId plobj = Autodesk.AutoCAD.Internal.Utils.EntLast();
Sending to it other method as below:
CommandWrapper.HatchPolyLine(plobj);
Here i am trying to hatch to drawn above polyline using below code but i am getting error message 'e.Message = "eInvalidInput"' at 'hatch.AppendLoop(HatchLoopTypes.Default, objectIdColletion);'
Kindly suggest where i did mistake in whole code.
public static void HatchPolyLine(ObjectId plobj){
try{
if (plobj != null){
Polyline pline = null;
Document document = Application.DocumentManager.MdiActiveDocument;
using (Transaction transaction = document.Database.TransactionManager.StartTransaction()){
pline = (Polyline)transaction.GetObject(plobj, OpenMode.ForWrite);
using (BlockTable blockTable = CADDBUtil.GetBlockTable(transaction))
using (BlockTableRecord modelSpace = CADDBUtil.GetModelSpace(transaction, blockTable))
using (Hatch hatch = new Hatch())
{
modelSpace.UpgradeOpen();
ObjectIdCollection objectIdColletion = new ObjectIdCollection();
objectIdColletion.Add(pline.Id);
hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
modelSpace.AppendEntity(hatch);
transaction.AddNewlyCreatedDBObject(hatch, true);
hatch.AppendLoop(HatchLoopTypes.Default, objectIdColletion);
hatch.EvaluateHatch(true);
pline.Color = hatch.Color;
}
transaction.Commit();
}
}
}
catch (Exception e)
{
throw new Exception(e.Message);
}
}
Solved! Go to Solution.