- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I am trying to create a command that converts 3DSolid entities to Mesh (not PolyFaceMesh). (Part of a bigger command).
I couldn't find a direct way of converting using the .Net API so have looked at calling MESHSMOOTH through Editor.Command(). The code below runs with no errors but no changes are made to the solids. The same solids convert successfully if I manually call the command on the AutoCAD command line. If I change the code and switch the passed in command to ERASE then the process works. So are there certain AutoCAD commands that do not support being called from Editor.Command()?
Also, if anyone knows how to convert 3DSolid to Mesh using .NET API I would be grateful to know!
[Autodesk.AutoCAD.Runtime.CommandMethod("VCY_CreateMesh", CommandFlags.UsePickSet)]
public void CreateMesh()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptSelectionResult psr = null;
TypedValue[] filterlist = new TypedValue[2];
//select only 3DSOLIDs
filterlist[0] = new TypedValue(0, "3DSOLID");
//8 = DxfCode.LayerName
filterlist[1] = new TypedValue(8, "Roads,Terrain");
SelectionFilter filter = new SelectionFilter(filterlist);
psr = ed.SelectAll(filter);
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
ed.Command("_.MESHSMOOTH", psr.Value, ""); // doesn't work
//ed.Command("_.ERASE", psr.Value, ""); // does work
// Do i need a transaction when calling ed.Command?
tr.Commit();
}
}
Solved! Go to Solution.