- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello dear developers.
I'm currently working on a feature that adds dimensions to 3D Solid.
That red line is the CAD UI function after changing the UCS. I'm trying to make it a CAD API.
The yellow dimension is the dimension created with the API.
As you can see the dimensions are messed up.
I am still stuck because I do not know how to use UCS as API Code.
Please help.
As an aside,
I hope this work will help you get to know UCS.
Are there any sites where I can study UCS and spatial coordinates in various ways?
[CommandMethod("DIMADD")]
public static void DIMADD()
{
editor = acap.DocumentManager.MdiActiveDocument.Editor;
// Get the current document and database, and start a transaction
Document doc = acap.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
// select a line
PromptEntityOptions options = new PromptEntityOptions(
"\nSelect an Solid3D Entity: ");
options.SetRejectMessage("\nSelect Solid3D");
options.AddAllowedClass(typeof(Solid3d), false);
PromptEntityResult res = editor.GetEntity(options);
// if ok
if (res.Status != PromptStatus.OK)
return;
double width = 1600;
double height = 800;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable btl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = null;
// Open the Block table record Model space for write
BlockTableRecord ms;
ms = tr.GetObject(btl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// select Solid
Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead);
if (ent.GetType() != typeof(Solid3d)) { editor.WriteMessage("It's not Solid3d."); return; }
Solid3d solid = ent as Solid3d;
using (Brep brep = new Brep(solid))
{
BrepEdgeCollection edges = brep.Edges;
foreach (Edge edge in edges)
{
Curve3d curve = ((ExternalCurve3d)edge.Curve).NativeCurve;
if (curve is LineSegment3d)
{
LineSegment3d line = curve as LineSegment3d;
Point3d dimpt1 = curve.StartPoint;
Point3d dimpt2 = curve.EndPoint;
Point3d dimcpt = CADUtil.GetCenterPts(new Point3d[] { dimpt1, dimpt2 });
dimcpt = new Point3d(dimcpt.X, dimcpt.Y + 200, dimcpt.Z);
// Here, i don't know how to apply ucs to my dimension point3d.
{
}
// Dimension
RotatedDimension acRotDim = new RotatedDimension();
acRotDim.SetDatabaseDefaults();
acRotDim.XLine1Point = dimpt1;
acRotDim.XLine2Point = dimpt2;
//acRotDim.Rotation = line.Angle;
acRotDim.DimLinePoint = dimcpt;
acRotDim.Layer = "0";
acRotDim.Dimtxt = 50;
acRotDim.Dimtad = 1;
ms.AppendEntity(acRotDim);
tr.AddNewlyCreatedDBObject(acRotDim, true);
}
}
}
tr.Commit();
}
}
Thanks for reading, have a good weekend.
Solved! Go to Solution.
Link copied