Search the Community
Showing results for tags '.net api'.
-
Hello guys, I'm trying to do a intersection dynamic block (name = "handrail") with user selected Line. This dynamic block is made up of polylines only. In the intersections points a need make a circles. This is my code, but is not working with dynamic block, only with static block. public static void FindIntersection(List<ObjectId> polylineIds) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions peo2 = new PromptEntityOptions("\nSelect a Line: "); peo2.SetRejectMessage("\nError, please select a Line"); peo2.AddAllowedClass(typeof(Line), true); PromptEntityResult res2 = ed.GetEntity(peo2); if (res2.Status != PromptStatus.OK) { return; } ObjectId lineId = polylineIds[0]; ObjectId line2Id = res2.ObjectId; Database db = Application.DocumentManager.MdiActiveDocument.Database; using (Transaction trans = db.TransactionManager.StartTransaction()) { Polyline poly = trans.GetObject(lineId, OpenMode.ForRead) as Polyline; Line line = trans.GetObject(line2Id, OpenMode.ForRead) as Line; BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Line line2 = new Line(); line2.StartPoint = poly.StartPoint; line2.EndPoint = poly.EndPoint; line2.ColorIndex = 1; btr.AppendEntity(line2); trans.AddNewlyCreatedDBObject(line2, true); Point3dCollection intersectionPoints = new Point3dCollection(); line.IntersectWith(poly, Intersect.OnBothOperands, intersectionPoints, 0, 0); Point3d intersectionPoint = intersectionPoints[0]; double radius = 25.0; // Průměr 50 Circle circle = new Circle(intersectionPoint, Vector3d.ZAxis, radius); btr.AppendEntity(circle); trans.AddNewlyCreatedDBObject(circle, true); trans.Commit(); } } [CommandMethod("Intersections")] public static void CountPolylinesInBlock() { var doc = Application.DocumentManager.MdiActiveDocument; var db = doc.Database; var ed = doc.Editor; string blockName = "Handrail"; var polylineIds = new List<ObjectId>(); using (Transaction tr = db.TransactionManager.StartTransaction()) { var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); if (!bt.Has(blockName)) { ed.WriteMessage($"\nBlok '{blockName}' not found."); return; } var blkRecId = bt[blockName]; var blkRec = (BlockTableRecord)tr.GetObject(blkRecId, OpenMode.ForRead); foreach (ObjectId id in blkRec) { Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity; if (ent != null && ent is Polyline) { polylineIds.Add(id); } } tr.Commit(); } FindIntersection(polylineIds); }
-
How to view CAD Drawing file in major Browsers
venkat_src posted a topic in The CUI, Hatches, Linetypes, Scripts & Macros
Dears, I am in need of any DLL or API (free / very low cost) to view the Autocad drawing file through my web-map application which was developed by using ASP.Net (C#). I got an opensource tool, that is Sharecad.org's iframe tool. But it requires the internet and public IP in the server to read our .dwg file. But my environment and requirements are viewing the dwg files without installing any Autocad software in intranet systems which are connected in LAN Network and read only option is enough with basic zoom in, zoom out and pan options. Seeking your suggestion and solution and it is more helpful to me. Thanks in Advance.- 2 replies
-
- viewer
- autocad .net
-
(and 3 more)
Tagged with:
-
In ACAD2014, a custom application generating lines and text entity was unable to execute immediately after saveAs the DWG(It raises a fatal error). But the same application was able execute when re-open the same DWG. How to solve this?
-
Activate or Deactivate DisplayTheme in DWG using .NET API
zetazee posted a topic in .NET, ObjectARX & VBA
Hi, I have 2 display themes in my DWG, and would like to use the .NET API to activate one display theme and deactivate the other. I have searched AutoCAD forums and here, but there wasn't any threads on this. Current findings so far. Showing part of my code. DisplayTheme has the public data member IsActive, and I was able to access the 2 display themes in my DWG, whereby one is active, the other is not. Search through the list of DisplayTheme public methods, but there was not any that could activate or deactivate it. DisplayTheme dt = tm.GetObject(id, OpenMode.ForWrite) as DisplayTheme; ed.WriteMessage(dt.IsActive + "\n"); Any assistance would be great. Thanks.