f.fhelix Posted March 10, 2023 Share Posted March 10, 2023 Good Night everyone, i am new on this C# world, i need to do run in Auto cad Plant 3D the following. 1- i will make 3D model containing navite grid line from struct grid. 2- I Will generate view ports for Orthoviews 3- Now I want to pick the view port and my C# code recognizes the gridline and draw grid bubbles and position them in my drawing. I've make the code but it says a lot of errors, i get no clue what is going on. does anybody can help please? using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Runtime; using Autodesk.ProcessPower.PnP3dObjects; public void DrawGridLine() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor acEd = acDoc.Editor; // Select viewport PromptEntityOptions peo = new PromptEntityOptions("\nSelect viewport: "); peo.SetRejectMessage("\nPlease select a valid viewport."); peo.AddAllowedClass(typeof(Viewport), true); PromptEntityResult per = acEd.GetEntity(peo); if (per.Status != PromptStatus.OK) { acEd.WriteMessage("\nError selecting viewport."); return; } Viewport vp = (Viewport)per.ObjectId.GetObject(OpenMode.ForWrite); // Draw grid line Gridstruct gs = new Gridstruct(); gs.LayerName = "GRID"; gs.GridColor = Color.FromColorIndex(ColorMethod.ByAci, 8); gs.GridLineStyle = LineStyle.Solid; gs.GridLineWeight = LineWeight.LineWeight015; gs.GridSpacing = 100; double x1 = vp.ViewCenter.X - vp.Width / 2.0; double y1 = vp.ViewCenter.Y - vp.Height / 2.0; double x2 = vp.ViewCenter.X + vp.Width / 2.0; double y2 = vp.ViewCenter.Y + vp.Height / 2.0; Point3d startPoint = new Point3d(x1, y1, 0); Point3d endPoint = new Point3d(x2, y1, 0); gs.CreateGridLine(startPoint, endPoint, vp.NumberOfColumns); acCurDb.AddToModelSpace(gs); acDoc.TransactionManager.QueueForGraphicsFlush(); acDoc.TransactionManager.FlushGraphics(); } Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 13, 2023 Share Posted March 13, 2023 I moved your thread to the .NET, ObjectARX & VBA Forum. Please post in the most relevant forum. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.