using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Windows.Data; using System; using System.Text; public class DataStuff { [CommandMethod("HL")] static public void GetHatchPatterns() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database db = acDoc.Database; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Transaction tr = acDoc.Database.TransactionManager.StartTransaction(); var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); PromptPointResult ppr; PromptPointOptions ppo = new PromptPointOptions(""); ppo.Message = "\n Select the place for print output:"; //get the coordinates from user ppr = ed.GetPoint(ppo); if (ppr.Status != PromptStatus.OK) return; Point3d startPoint = ppr.Value.TransformBy(ed.CurrentUserCoordinateSystem); Vector3d disp = new Vector3d(0.0, -2.0 * db.Textsize, 0.0); //Vector3d disp2 = new Vector3d(0.0, -2.0 * db.Textsize, 0.0); // HatchPatterns hatc = tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead) as HatchPatterns; Hatch hat = new Hatch(); foreach (string str in HatchPatterns.Instance.AllPatterns) { if (hat.PatternName == "ANSI32" && hat.PatternScale == 10.0 || hat.PatternName == "ANSI35" && hat.PatternScale == 10.00 || hat.PatternName == "AR-CONC" && hat.PatternScale == 0.2 || hat.PatternName == "AR-SAND" && hat.PatternScale == 0.2 || hat.PatternName == "EARTH" && hat.PatternScale == 10 && hat.PatternAngle == 0 || hat.PatternName == "EARTH" && hat.PatternScale == 10 && hat.PatternAngle == 315 || hat.PatternName == "ANSI34" && hat.PatternScale == 3.0 && hat.PatternAngle == 45 || hat.PatternName == "AR-HBONE" && hat.PatternScale == 0.5 && hat.PatternAngle == 270 || hat.PatternName == "HONEY" && hat.PatternScale == 5.0 && hat.PatternAngle == 270 || hat.PatternName == "ZIGZAG" && hat.PatternScale == 2.0 && hat.PatternAngle == 45 || hat.PatternName == "ANSI31" && hat.PatternScale == 5.0 && hat.PatternAngle == 0 || hat.PatternName == "ANSI31" && hat.PatternScale == 500.0 && hat.PatternAngle == 0 || hat.PatternName == "GRASS" && hat.PatternScale == 0.15 && hat.PatternAngle == 0 || hat.PatternName == "GRASS" && hat.PatternScale == 100.0 && hat.PatternAngle == 0 || hat.PatternName == "SACNCR" && hat.PatternScale == 500.0 && hat.PatternAngle == 0 || hat.PatternName == "NET3" && hat.PatternScale == 500 && hat.PatternAngle == 0 || hat.PatternName == "ZIGZAG" && hat.PatternScale == 1000.0 && hat.PatternAngle == 0) { ed.WriteMessage("Valid hatch used:"); } else { ed.WriteMessage("This hatches are not allowed:" + "\n" + hat.PatternName); } } tr.Commit(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)