Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
[CommandMethod("ha")]
       public static void FindAllHatches()
       {
           float x = 25, y = 15, z;
           Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
           Document acDoc = Application.DocumentManager.MdiActiveDocument;
 
           var db = acDoc.Database;
           using (Transaction transaction = db.TransactionManager.StartTransaction())
           {
               ObjectId idModelSpace = SymbolUtilityServices.GetBlockModelSpaceId(db);
 
               BlockTableRecord modelSpace = transaction.GetObject(idModelSpace, OpenMode.ForWrite) as
                   BlockTableRecord;
 
               foreach (var objId in modelSpace)
               {
                   MText mtext = new MText();
                   mtext.Width = 6;
                   mtext.Location = new Point3d(x, y, z = 0);
                   ////acpt = new Point3d(acpt.X, acpt.Y + 2, acpt.Z);

                   var entity = transaction.GetObject(objId, OpenMode.ForRead);
                   Hatch hatch = entity as Hatch;
                   if (hatch == null)
                       continue; //not hatch

                   mtext.Contents = ("\n" + "\n The area of hatch is: " + hatch.Area + hatch.PatternName + hatch.Color);
 
                   acDoc.Editor.WriteMessage("\n" + "\n The area of hatch is:" + hatch.Area + hatch.PatternName + hatch.Color);
 
                   modelSpace.AppendEntity(mtext);
                   transaction.AddNewlyCreatedDBObject(mtext, true);
                   y--;
               }
               transaction.Commit();
           }
       }


What I have tried:

The output of the above code is area of hatches in the drawing and i want to display the output to the user specified points bt that points i want to get by cursor i.e.entered by or mouse click.
Posted
Updated 20-Jul-16 20:41pm
Comments
lukeer 20-Jul-16 11:29am    
I don't quite get your question. Do you want to print text to a user-defined location?
Do you want to draw something in 3-d space?
@j@y123 21-Jul-16 0:04am    
yes. My code is calculate the area of hatches and i want to print it to user defined location but i am confuse that how can i get user defined location?

1 solution

The MousePosition property of your Form, Panel, whatever you're drawing your stuff on will tell you where the mouse pointer is.
Bear in mind that you get screen co-ordinates, even though you're calling a control's method. To print something, you will typically need control co-ordinates. Control.PointToClient will translate for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900