public static Hatch CreateHatch(ObjectId ID, string Type, Color C) { var Return = new Hatch(); using (Transaction T = Doc.TransactionManager.StartTransaction()) { var BT = T.GetObject(DB.BlockTableId, OpenMode.ForRead) as BlockTable; var BTR = T.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Return.SetDatabaseDefaults(); var OC = new ObjectIdCollection(); OC.Add(ID); Return.SetDatabaseDefaults(); Return.SetHatchPattern(HatchPatternType.PreDefined, Type); Return.Associative = true; Return.AppendLoop(HatchLoopTypes.Default, OC); Return.EvaluateHatch(true); Return.Color = C; BTR.AppendEntity(Return); T.AddNewlyCreatedDBObject(Return, true); T.Commit(); } return(Return); }
/// <summary> /// 绘制填充 /// </summary> /// <param name="db">CAD数据库</param> /// <param name="pl">外轮廓多线</param> /// <param name="href">填充参考样式</param> /// <param name="scale">填充比例,默认=1</param> /// <returns>返回填充对象</returns> public static Hatch PlotH(Database db, Polyline pl, Hatch href, double scale = 1) { Hatch hatch1 = new Hatch(); using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; hatch1.SetHatchPattern(href.PatternType, href.PatternName); modelSpace.AppendEntity(hatch1); tr.AddNewlyCreatedDBObject(hatch1, true); hatch1.PatternScale = href.PatternScale; hatch1.Layer = "填充"; hatch1.Associative = true; hatch1.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection { pl.ObjectId }); hatch1.EvaluateHatch(true); hatch1.PatternScale = href.PatternScale; hatch1.SetHatchPattern(hatch1.PatternType, hatch1.PatternName); tr.Commit(); } return(hatch1); }
/// <summary> /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/> /// </summary> public override void OnSetAction() { // die Titel Ids müssen sich unterscheiden, auch wg. der Hilfe string resSubId = ""; switch (mode) { case HatchMode.simple: resSubId = "InnerPoint"; break; case HatchMode.hull: resSubId = "Hull"; break; case HatchMode.excludeHoles: resSubId = "ExcludeHoles"; break; } base.TitleId = "Constr.Hatch." + resSubId; ConstructAction.GeoPointInput gpi = new GeoPointInput("Constr.Hatch.InnerPoint.Point"); gpi.SetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.SetGeoPointDelegate(OnPoint); gpi.MouseClickEvent += new MouseClickDelegate(OnMouseClick); base.UseFilter = true; base.ShowAttributes = true; base.ShowActiveObject = false; base.ActiveObject = Hatch.Construct(); base.SetInput(gpi); base.OnSetAction(); }
private void AddHatchingArrow(IList <Entity> entity) { using (var transaction = CADProxy.Database.TransactionManager.StartTransaction()) { var polyline = new Polyline(); polyline.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0); polyline.AddVertexAt(0, new Point2d(1.5, 1.5), 0, 0, 0); polyline.AddVertexAt(0, new Point2d(0, 1.5), 0, 0, 0); polyline.Closed = true; var blockTableRecord = transaction.GetObject(CADProxy.Database.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; var objIds = new ObjectIdCollection() { blockTableRecord.AppendEntity(polyline) }; transaction.AddNewlyCreatedDBObject(polyline, true); var hatch = new Hatch(); hatch.SetDatabaseDefaults(); hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = false; hatch.AppendLoop((int)HatchLoopTypes.Default, objIds); hatch.EvaluateHatch(true); polyline.Erase(); entity.Add(hatch); } }
public static void OnPatternChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { Hatch v = (Hatch)e.NewValue; HatchCanvas h = (HatchCanvas)d; h.Update(v, 1); }
Hatch CloneHatch(Hatch oldEnt) { try { Hatch newEnt = new Hatch(); for (int hi = 0; hi < oldEnt.NumberOfLoops; hi++) { HatchLoop hl = oldEnt.GetLoopAt(hi); newEnt.AppendLoop(hl); } newEnt.Associative = oldEnt.Associative; newEnt.BackgroundColor = oldEnt.BackgroundColor; newEnt.Elevation = oldEnt.Elevation; //newEnt.GradientAngle = oldEnt.GradientAngle; //newEnt.GradientOneColorMode = oldEnt.GradientOneColorMode; //newEnt.GradientShift = oldEnt.GradientShift; newEnt.HatchObjectType = oldEnt.HatchObjectType; newEnt.HatchStyle = oldEnt.HatchStyle; newEnt.Normal = oldEnt.Normal; newEnt.Origin = oldEnt.Origin; newEnt.PatternAngle = oldEnt.PatternAngle; newEnt.PatternDouble = oldEnt.PatternDouble; newEnt.PatternScale = oldEnt.PatternScale; newEnt.PatternSpace = oldEnt.PatternSpace; //newEnt.ShadeTintValue = oldEnt.ShadeTintValue; return(newEnt); } catch (Exception ex) { Logger.log("CloneHatch", ex.Message); } return(null); }
public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd) { var line = drawable as Line; if (line != null) { //delta,这条直线所代表的三维向量 var vec = line.Delta.RotateBy(Math.PI / 2, Vector3d.ZAxis).GetNormal(); var pts = new Point3dCollection() { line.StartPoint + vec, line.EndPoint + vec, line.EndPoint - vec, line.StartPoint - vec, }; wd.Geometry.Polygon(pts); var hatch = new Hatch(); var pts2d = new Point2dCollection(); var bulge = new DoubleCollection(); foreach (Point3d pt3d in pts) { pts2d.Add(new Point2d(pt3d.X, pt3d.Y)); bulge.Add(0); } hatch.AppendLoop(HatchLoopTypes.Default, pts2d, bulge); hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE"); hatch.WorldDraw(wd); } return(base.WorldDraw(drawable, wd)); }
private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { if (e.Item.Type == EntityType.Leader) { Leader leader = (Leader)e.Item; if (leader.Annotation != null) { entities.Add(leader.Annotation); } } else if (e.Item.Type == EntityType.Hatch) { Hatch hatch = (Hatch)e.Item; foreach (HatchBoundaryPath path in hatch.BoundaryPaths) { foreach (EntityObject entity in path.Entities) { entities.Add(entity); } } } OnEntityAddedEvent(e.Item); e.Item.Owner = this; }
public static Hatch FindHatchToLeft(BlockTableRecord mSpace, Transaction trans, MText text) { LineSegment3d current = new LineSegment3d(text.Bounds.Value.MinPoint, text.Bounds.Value.MaxPoint); Line3d lineUp = new Line3d(current.MidPoint, Vector3d.XAxis); double distance = double.MaxValue; Hatch ret = null; foreach (ObjectId entId in mSpace) { Hatch thisHatch = trans.GetObject(entId, OpenMode.ForRead) as Hatch; if (thisHatch == null) { continue; } LineSegment3d thisHatchLine = new LineSegment3d(thisHatch.Bounds.Value.MinPoint, thisHatch.Bounds.Value.MaxPoint); Point3d[] intersectionPoints = lineUp.IntersectWith(thisHatchLine); if (intersectionPoints == null || intersectionPoints.Length != 1) { continue; } double thisDistance = current.MidPoint.DistanceTo(intersectionPoints[0]); if (thisDistance < distance && !thisHatch.ObjectId.Equals(text.ObjectId) && current.MidPoint.X > intersectionPoints[0].X) { distance = thisDistance; ret = thisHatch; } } return(ret); }
public string Print() { return("Name: " + Pokemon + ", National Pokedex Number: " + Per.ToString() + ", Regional Pokedex Number: " + Nat + ", Base HP: " + HP.ToString() + ", Base Attack: " + Atk.ToString() + ", Base Defense: " + Def.ToString() + ", Base Sp.Attack: " + SpA.ToString() + ", Base Sp.Def: " + SpD.ToString() + ", Base Speed: " + Spe.ToString() + ", Total Base Stats: " + Total.ToString() + ", Type I: " + Type_I + ", Type II: " + Type_II + ", Tier: " + Tier + ", Ability I: " + Ability_I + ", Ability II: " + Ability_II + ", Hidden Ability: " + Hidden_Ability + ", Mass: " + Mass + ", Low Kick/Grass Knot damage: " + LK_GK.ToString() + ", EV Worth: " + EV_Worth + ", Exp Value: " + EXPV.ToString() + ", Pokedex Color: " + Color + ", Hatch: " + Hatch.ToString() + ", Gender" + Gender + ", Egg Group I: " + Egg_Group_I + ", Egg Group II: " + Egg_Group_II + ", Catch Rate: " + Catch.ToString() + ", Leveling Rate: " + LevelingRate()); }
/// <summary> /// 创建填充。 /// </summary> /// <param name="pattern"></param> /// <param name="loops"></param> /// <param name="type"></param> /// <param name="scale"></param> /// <param name="otherSetting"></param> /// <param name="db"></param> /// <param name="space"></param> /// <returns></returns> public static ObjectId CreateHatch(string pattern, Polyline[] loops, HatchPatternType type = HatchPatternType.PreDefined, double scale = 1, Action <Hatch> otherSetting = null, Database db = null, string space = null) { var hatch = new Hatch(); var id = hatch.ToSpace(db, space); using (var trans = id.Database.TransactionManager.StartTransaction()) { hatch = trans.GetObject(id, OpenMode.ForWrite) as Hatch; hatch.PatternScale = scale; hatch.SetHatchPattern(type, pattern); foreach (var loop in loops) { var hatchLoop = new HatchLoop(HatchLoopTypes.Polyline); for (var i = 0; i < loop.NumberOfVertices; i++) { hatchLoop.Polyline.Add( new BulgeVertex(loop.GetPoint2dAt(i), loop.GetBulgeAt(i))); } hatch.AppendLoop(hatchLoop); } otherSetting?.Invoke(hatch); trans.Commit(); } return(id); }
// 由边界对象集合数组、图案填充类型、填充图案名称、填充角度和填充比例创建图案填充的函数. // partType:0为预定义图案;1为用户定义图案;2为自定义图案. public static ObjectId AddHatch(ObjectIdCollection[] objIds, HatchPatternType patType, string patName, double patternAngle, double patternScale) { try { Hatch ent = new Hatch(); ent.HatchObjectType = HatchObjectType.HatchObject; Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); ObjectId entId = btr.AppendEntity(ent); trans.AddNewlyCreatedDBObject(ent, true); ent.PatternAngle = patternAngle; ent.PatternScale = patternScale; ent.SetHatchPattern(patType, patName); ent.Associative = true; for (int i = 0; i < objIds.Length; i++) { ent.InsertLoopAt(i, HatchLoopTypes.Default, objIds[i]); } trans.Commit(); return(entId); } } catch { ObjectId nullId = ObjectId.Null; return(nullId); } }
/// <since>5.0</since> public bool SetFromHatch(Hatch hatch) { IntPtr pThis = NonConstPointer(); IntPtr pConstHatch = hatch.ConstPointer(); return(UnsafeNativeMethods.CRhinoGumball_SetFromHatch(pThis, pConstHatch)); }
public void AddHatch() { Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument; Database database = mdiActiveDocument.Database; using (Transaction transaction = database.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, 0); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], 1); Circle circle = new Circle(); circle.SetDatabaseDefaults(); Circle circle2 = circle; Point3d center; center..ctor(3.0, 3.0, 0.0); circle2.Center = center; circle.Radius = 10000.0; blockTableRecord.AppendEntity(circle); transaction.AddNewlyCreatedDBObject(circle, true); ObjectIdCollection objectIdCollection = new ObjectIdCollection(); objectIdCollection.Add(circle.ObjectId); Hatch hatch = new Hatch(); blockTableRecord.AppendEntity(hatch); transaction.AddNewlyCreatedDBObject(hatch, true); hatch.SetDatabaseDefaults(); hatch.SetHatchPattern(1, "ANSI31"); hatch.Associative = true; hatch.AppendLoop(16, objectIdCollection); hatch.EvaluateHatch(true); transaction.Commit(); } }
private void AddHatchingArrow(IList <Entity> entityList) { var hatch = new Hatch(); using (var tr = CADProxy.Database.TransactionManager.StartTransaction()) { var bd = new Polyline(); bd.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0); bd.AddVertexAt(0, new Point2d(-2.5, 3), 0, 0, 0); bd.AddVertexAt(0, new Point2d(2.5, 3), 0, 0, 0); bd.Closed = true; BlockTable bt = tr.GetObject(CADProxy.Database.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord btr = tr.GetObject(CADProxy.Database.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; var bdId = btr.AppendEntity(bd); tr.AddNewlyCreatedDBObject(bd, true); ObjectIdCollection ObjIds = new ObjectIdCollection { bdId }; hatch.SetDatabaseDefaults(); hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = false; hatch.AppendLoop((int)HatchLoopTypes.Default, ObjIds); hatch.EvaluateHatch(true); bd.Erase(); } entityList.Add(hatch); }
/// <summary> /// 图案填充 无颜色 /// </summary> /// <param name="db">图形数据库</param> /// <param name="patternName">图案名称</param> /// <param name="scale">填充比例</param> /// <param name="degree">旋转角度</param> /// <param name="entid">边界图形的ObjectId</param> /// <returns></returns> public static ObjectId HatchEnity(this Database db, string patternName, double scale, double degree, ObjectId entid) { ObjectId hatchId = ObjectId.Null; using (Transaction trans = db.TransactionManager.StartTransaction()) { // 声明一个图案填充对象 Hatch hatch = new Hatch(); // 设置填充比例 hatch.PatternScale = scale; // 设置填充类型和图案名称 hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE"); // 加入图形数据库 BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); hatchId = btr.AppendEntity(hatch); trans.AddNewlyCreatedDBObject(hatch, true); // 设置填充角度 hatch.PatternAngle = degree; // 设置关联 hatch.Associative = true; // 设置边界图形和填充方式 ObjectIdCollection obIds = new ObjectIdCollection(); obIds.Add(entid); hatch.AppendLoop(HatchLoopTypes.Outermost, obIds); // 计算填充并显示 hatch.EvaluateHatch(true); // 提交事务 trans.Commit(); } return(hatchId); }
public string GetProjectHatches(int ProjectID) { Project p = new Project(); DataTable dt = p.GetProjectHatches(ProjectID); ArrayList[] myAL = new ArrayList[dt.Rows.Count]; for (int i = 0; i < myAL.Length; i++) { myAL[i] = new ArrayList(); } Hatch h = new Hatch(); for (int i = 0; i < myAL.Length; i++) { h = new Hatch(); h.HatchID = Convert.ToInt32(dt.Rows[i].ItemArray[0]); h.HatchStatus = dt.Rows[i].ItemArray[2].ToString(); h.FtName = dt.Rows[i].ItemArray[5].ToString(); h.Comments = dt.Rows[i].ItemArray[6].ToString(); myAL[i].Add(h); } // create a json serializer object JavaScriptSerializer js = new JavaScriptSerializer(); // serialize to string string jsonString = js.Serialize(myAL); return(jsonString); }
private static void FillContour(BlockSectionKP bs, Polyline plExtern, BlockTableRecord cs, Transaction t) { var h = new Hatch(); h.SetDatabaseDefaults(); h.Layer = OptionsKPBS.Instance.LayerBSContourGNS; h.LineWeight = LineWeight.LineWeight015; h.Linetype = SymbolUtilityServices.LinetypeContinuousName; h.Color = GetFillColor(bs); // Color.FromRgb(250, 250, 250); //h.Transparency = new Transparency(80); h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); cs.AppendEntity(h); t.AddNewlyCreatedDBObject(h, true); h.Associative = true; h.HatchStyle = HatchStyle.Normal; // добавление контура полилинии в гштриховку var ids = new ObjectIdCollection(); ids.Add(plExtern.Id); h.AppendLoop(HatchLoopTypes.Default, ids); h.EvaluateHatch(true); var orders = cs.DrawOrderTableId.GetObject(OpenMode.ForWrite) as DrawOrderTable; orders.MoveToBottom(new ObjectIdCollection(new[] { h.Id })); }
public void DrawObject() { for (int i = 0; i < DistanceCalculate.hatches.Count; i++) { //curState.text = DistanceCalculate.hatches[i].state.ToString(); if (DistanceCalculate.hatches[i].state == State.unDrawed) { //postext.text = DistanceCalculate.hatches[i].position.ToString(); shift = arCamera.transform.position + DistanceCalculate.hatches[i].position; DistanceCalculate.hatches[i].model = Instantiate(prefab, shift, Quaternion.identity); tempHatch = DistanceCalculate.hatches[i].model.GetComponent <Hatch>(); tempHatch.description = DistanceCalculate.hatches[i].description; tempHatch.location.latitude = DistanceCalculate.hatches[i].location.latitude; tempHatch.location.longitude = DistanceCalculate.hatches[i].location.longitude; spawn.text = "spawned"; //m_SessionOrigin.MakeContentAppearAt(DistanceCalculate.hatches[i].model.transform, arCamera.transform.position, Quaternion.identity); // //m_SessionOrigin.MakeContentAppearAt(DistanceCalculate.hatches[i].model.transform, DistanceCalculate.hatches[i].position, Quaternion.identity);// DistanceCalculate.hatches[i].state = State.drawed; } if (DistanceCalculate.hatches[i].state == State.toErase) { Destroy(DistanceCalculate.hatches[i].model); DistanceCalculate.hatches[i].state = State.toDelete; } } }
// 由图案填充类型、填充图案名称、 // 填充角度和填充比例创建图案填充的函数. // partType:0为预定义图案;1为用户定义图案;2为自定义图案. private ObjectId AddHatch(out Hatch hatchEnt, HatchPatternType patType, String patName, Double patternAngle, Double patternScale) { Hatch ent = new Hatch(); ent.HatchObjectType = HatchObjectType.HatchObject; Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)trans.GetObject (db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)trans.GetObject (bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); ObjectId entId = btr.AppendEntity(ent); trans.AddNewlyCreatedDBObject(ent, true); ent.SetDatabaseDefaults(); ent.PatternAngle = patternAngle; ent.PatternScale = patternScale; ent.SetHatchPattern(patType, patName); hatchEnt = ent; trans.Commit(); return(entId); } }
/*Draw Hatch*/ public static void DrawHatch(Hatch xHatch, Canvas mainCanvas) { System.Windows.Point p0 = new System.Windows.Point(); System.Windows.Shapes.Path wPath = new System.Windows.Shapes.Path(); List <PathSegment> segments = new List <PathSegment>(); PathSegment segment; List <PathFigure> figures = new List <PathFigure>(); int i = 0; foreach (netDxf.Entities.HatchBoundaryPath xPath in xHatch.BoundaryPaths) { segments = new List <PathSegment>(); Debug.WriteLine("xpath:" + xPath.PathType); int j = 0; foreach (netDxf.Entities.HatchBoundaryPath.Edge xEdge in xPath.Edges) { Debug.WriteLine("xEdge:" + xEdge.Type); if (xEdge.Type == netDxfPath.EdgeType.Line) { netDxfPath.Line wLine = (netDxfPath.Line)xEdge; segment = new LineSegment(TypeConverter.Vertex2ToPoint(wLine.End, mainCanvas.Height), true); segments.Add(segment); if (j == 0) { p0 = TypeConverter.Vertex2ToPoint(wLine.Start, mainCanvas.Height); } } j++; /*if(xEdge.Type==netDxf.Entities.HatchBoundaryPath.EdgeType.Line) DrawLine((netDxf.Entities.Line)xEdge.ConvertTo(),mainCanvas); * if(xEdge.Type==netDxf.Entities.HatchBoundaryPath.EdgeType.Ellipse) DrawEllipse((netDxf.Entities.Ellipse)xEdge.ConvertTo(),mainCanvas); * if(xEdge.Type==netDxf.Entities.HatchBoundaryPath.EdgeType.Spline) DrawSpline((netDxf.Entities.Spline)xEdge.ConvertTo(),mainCanvas); * if(xEdge.Type==netDxf.Entities.HatchBoundaryPath.EdgeType.Arc) DrawArc((netDxf.Entities.Arc)xEdge.ConvertTo(),mainCanvas); * if(xEdge.Type==netDxf.Entities.HatchBoundaryPath.EdgeType.Polyline) DrawLwPolyline((netDxf.Entities.LwPolyline)xEdge.ConvertTo(),mainCanvas); */ } PathFigure pf = new PathFigure(p0, segments, true); pf.IsClosed = false; figures.Add(pf); i++; } Geometry g = new PathGeometry(figures, FillRule.EvenOdd, null); wPath.Data = g; wPath.Fill = TypeConverter.PatternToBrush(xHatch.Pattern, xHatch.getColor()); TypeConverter.Entity2Shape(xHatch, wPath); wPath.StrokeThickness = 0; mainCanvas.Children.Add(wPath); }
/// <summary> /// Adds the predefined hatch. /// </summary> /// <param name="trans">The trans.</param> /// <param name="points">The points.</param> /// <param name="layername">The layername.</param> /// <param name="isClosed">if set to <c>true</c> [is closed].</param> /// <param name="patternName">Name of the pattern.</param> /// <returns></returns> public static ObjectId AddPredefinedHatch(Transaction trans, Point2dCollection points, string layername, bool isClosed, string patternName) { //_logger.Debug("Start AddPredefinedHatch"); ObjectId id = ObjectId.Null; Autodesk.AutoCAD.DatabaseServices.Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; using (Hatch hatch = new Hatch()) { hatch.SetDatabaseDefaults(); hatch.Layer = layername; id = AddToDatabase(db, hatch, trans); hatch.UpgradeOpen(); //hatch.HatchStyle = HatchStyle.Outer; hatch.Associative = true; hatch.PatternScale = 100.0; hatch.SetHatchPattern(HatchPatternType.PreDefined, patternName); double buldge = 0.0; HatchLoop loop = new HatchLoop(HatchLoopTypes.Polyline); foreach (Point2d pt in points) { BulgeVertex bv = new BulgeVertex(pt, buldge); loop.Polyline.Add(bv); } hatch.AppendLoop(loop); hatch.EvaluateHatch(true); } //_logger.Debug("End AddPredefinedHatch"); return(id); }
public static bool IsPointOnHatchByRay(this Hatch hatch, Point3d pt, Tolerance tolerance, Database db) { var hId = hatch.Id; try { if (hatch.Id.IsNull) { using var t = db.TransactionManager.StartTransaction(); var cs = db.CurrentSpaceId.GetObjectT <BlockTableRecord>(OpenMode.ForWrite); var hClone = (Hatch)hatch.Clone(); hId = cs.AppendEntity(hClone); t.AddNewlyCreatedDBObject(hClone, true); t.Commit(); } using var r = hId.CreateRegionFromHatch(); using var ray = new Ray { BasePoint = pt, UnitDir = new Vector3d(0.235, 0.7458, 0) }; var pts = new Point3dCollection(); ray.IntersectWith(r, Intersect.OnBothOperands, new Plane(), pts, IntPtr.Zero, IntPtr.Zero); return(pts.Count > 0 && (pts.Count.IsOdd() || pts.Cast <Point3d>().Any(p => p.IsEqualTo(pt)))); } finally { if (!hId.IsNull) { #pragma warning disable 618 using var h = hId.Open(OpenMode.ForWrite, false, true) as Hatch; #pragma warning restore 618 h?.Erase(); } } }
public void AddGradientHatch() { Database db = HostApplicationServices.WorkingDatabase; //创建一个三角形 Polyline triangle = new Polyline(); triangle.CreatePolygon(new Point2d(550, 200), 3, 30); using (Transaction trans = db.TransactionManager.StartTransaction()) { //将三角形添加到模型空间中 ObjectId triangleId = db.AddToModelSpace(triangle); //创建一个ObjectId集合类对象,用于存储填充边界的ObjectId ObjectIdCollection ids = new ObjectIdCollection { triangleId //将三角形的ObjectId添加到边界集合中 }; Hatch hatch = new Hatch(); //创建填充对象 //创建两个Color类变量,分别表示填充的起始颜色(红)和结束颜色(蓝) Color color1 = Color.FromColorIndex(ColorMethod.ByLayer, 1); Color color2 = Color.FromColor(System.Drawing.Color.Blue); //创建渐变填充,与边界无关联 hatch.CreateGradientHatch(HatchGradientName.Cylinder, color1, color2, false); //为填充添加边界(三角形) hatch.AppendLoop(HatchLoopTypes.Default, ids); hatch.EvaluateHatch(true); //计算并显示填充对象 trans.Commit(); //提交更改 } }
private void FillRectangle(DxfDocument dxf, Layer layer, double x, double y, double width, double height, ArgbColor color) { var fill = ToColor(color); var fillTransparency = ToTransparency(color); var bounds = new List <HatchBoundaryPath> { new HatchBoundaryPath( new List <EntityObject> { CreateLine(x, y, x + width, y), CreateLine(x + width, y, x + width, y + height), CreateLine(x + width, y + height, x, y + height), CreateLine(x, y + height, x, y) }) }; var hatch = new Hatch(HatchPattern.Solid, bounds, false); hatch.Layer = layer; hatch.Color = fill; hatch.Transparency.Value = fillTransparency; dxf.AddEntity(hatch); }
/// <summary> /// 创建填充。 /// </summary> /// <param name="pattern"></param> /// <param name="loops"></param> /// <param name="type"></param> /// <param name="scale"></param> /// <param name="otherSetting"></param> /// <param name="db"></param> /// <param name="space"></param> /// <returns></returns> public static ObjectId CreateHatch(string pattern, ObjectIdCollection loops, HatchPatternType type = HatchPatternType.PreDefined, double scale = 1, Action <Hatch> otherSetting = null, string space = null) { var hatch = new Hatch(); var id = hatch.ToSpace(loops[0].Database, space); using (var trans = id.Database.TransactionManager.StartTransaction()) { hatch = trans.GetObject(id, OpenMode.ForWrite) as Hatch; hatch.PatternScale = scale; hatch.SetHatchPattern(type, pattern); foreach (ObjectId loopId in loops) { hatch.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { loopId }); } otherSetting?.Invoke(hatch); trans.Commit(); } return(id); }
public void AddHatch() { Database db = HostApplicationServices.WorkingDatabase; using (Transaction trans = db.TransactionManager.StartTransaction()) { Hatch hatch = new Hatch(); //创建填充对象 hatch.ToSpace(); hatch.PatternScale = 0.5; //设置填充图案的比例 string patterName = DBHelper.CurrentPattern; //根据上面的填充图案名创建图案填充,类型为预定义,与边界关联 hatch.CreateHatch(HatchPatternType.PreDefined, patterName, true); for (int i = 0; i < this.objco.Count; i++) { if (i == 0) { //为填充添加外边界(正六边形) hatch.AppendLoop(HatchLoopTypes.Outermost, objco[i]); } else { //为填充添加外边界(正六边形) hatch.AppendLoop(HatchLoopTypes.Default, objco[i]); } } hatch.EvaluateHatch(true); //计算并显示填充对象 trans.Commit(); //提交更改 } }
private void OnMouseClick(bool up, GeoPoint MousePosition, IView View) { if (up) { if (base.ShowActiveObject) { Plane pln = Frame.ActiveView.Projection.DrawingPlane; GeoPoint2D onPlane = pln.Project(MousePosition); Hatch h = ActiveObject as Hatch; // GeoObjectVisualizer.TestShowVisualizer(h); if (!h.CompoundShape.Contains(onPlane, true)) { base.ShowActiveObject = false; } else { // das ActiveObject wird ja eingefügt, wenn die Aktion zu Ende ist } } else { if (debug) { FindShape(); if (base.ShowActiveObject) { // System.Diagnostics.Trace.WriteLine("Schraffur wird zugefügt: " + (base.ActiveObject as Hatch).CompoundShape.Area.ToString()); base.OnDone(); // ActiveObject ist OK } } } } }
public HatchDrawingObject CreateHatch(string patternName) { Transaction trans = _database.TransactionManager.TopTransaction; BlockTableRecord btr = _database.GetModelSpace(true); Hatch oHatch = new Hatch(); Vector3d normal = Vector3d.ZAxis; oHatch.Normal = normal; oHatch.Elevation = 0.0; oHatch.PatternScale = 1.0; oHatch.SetHatchPattern(HatchPatternType.PreDefined, patternName); btr.AppendEntity(oHatch); trans.AddNewlyCreatedDBObject(oHatch, true); oHatch.Associative = true; ObjectIdCollection acObjIdColl = new ObjectIdCollection(); acObjIdColl.Add(BaseObject); oHatch.AppendLoop(HatchLoopTypes.Default, acObjIdColl); oHatch.EvaluateHatch(true); return(new HatchDrawingObject(oHatch)); }
protected override void AcceptTextInput(InputArgs <string, CPSelectionSet> args) { args.InputValid = Point2D.TryParse(args.Input, out Point2D pt); if (args.InputValid) { if (!getFirstPoint) { firstPoint = pt; getFirstPoint = true; args.InputCompleted = false; consHatch = new Hatch(firstPoint, firstPoint, firstPoint, firstPoint); Editor.Document.Transients.Add(consHatch); consLine = new Polygon(firstPoint, firstPoint, firstPoint, firstPoint); Editor.Document.Transients.Add(consLine); } else { args.Value = GetSelectionFromWindow(); args.InputCompleted = true; Editor.Document.Transients.Remove(consHatch); Editor.Document.Transients.Remove(consLine); } } }
private void AutoClose(MudObject Player, Hatch Hatch) { if (Hatch.GetBooleanProperty("open?")) { Hatch.SetProperty("open?", false); var otherSide = Portal.FindOppositeSide(Hatch); if (otherSide != null) otherSide.SetProperty("open?", false); MudObject.SendMessage(Player, "^<the0> closes.", Hatch); } }
public static Hatch CreateHatch(this List<Point2d> pts) { pts = pts.DistinctPoints(); var ptCol = new Point2dCollection(pts.ToArray()); ptCol.Add(pts[0]); var dCol = new DoubleCollection(new double[pts.Count]); var h = new Hatch(); h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); h.AppendLoop(HatchLoopTypes.Default, ptCol, dCol); h.EvaluateHatch(false); return h; }
public HatchInfo(Hatch h) { Id = h.Id; if (h.Associative) { IdsAssociate = h.GetAssociatedObjectIds(); } PatternName = h.PatternName; PatternScale = h.PatternScale; PatternAngle = h.PatternAngle; PatternType = h.PatternType; Layer = h.Layer; Color = h.Color; Lineweight = h.LineWeight; }
public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t) { var cellWidth = ColorBookHelper.CellWidth; var cellHeight = ColorBookHelper.CellHeight; var margin = ColorBookHelper.Margin; var marginHalf = margin * 0.5; Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0); Polyline pl = new Polyline(4); pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0); pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0); pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0); pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0); pl.Closed = true; pl.SetDatabaseDefaults(); pl.Color = Color; cs.AppendEntity(pl); t.AddNewlyCreatedDBObject(pl, true); Hatch h = new Hatch(); h.SetDatabaseDefaults(); h.SetHatchPattern(HatchPatternType.PreDefined, "Solid"); h.Annotative = AnnotativeStates.False; cs.AppendEntity(h); t.AddNewlyCreatedDBObject(h, true); h.Associative = true; h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id })); h.Color = Color; h.EvaluateHatch(true); DBText text = new DBText(); text.SetDatabaseDefaults(); text.HorizontalMode = TextHorizontalMode.TextCenter; text.Annotative = AnnotativeStates.False; text.Height = ColorBookHelper.TextHeight; text.AlignmentPoint = ptText; text.AdjustAlignment(cs.Database); text.TextStyleId = ColorBookHelper.IdTextStylePik; text.TextString = Name; cs.AppendEntity(text); t.AddNewlyCreatedDBObject(text, true); }
/// <summary> /// Создание ассоциативной штриховки по полилинии /// Полилиния должна быть в базе чертежа /// </summary> public static Hatch CreateAssociativeHatch(Curve loop, BlockTableRecord cs, Transaction t, string pattern = "SOLID", string layer = null, LineWeight lw = LineWeight.LineWeight015) { var h = new Hatch(); h.SetDatabaseDefaults(); if (layer != null) { Layers.LayerExt.CheckLayerState(layer); h.Layer = layer; } h.LineWeight = lw; h.Linetype = SymbolUtilityServices.LinetypeContinuousName; h.SetHatchPattern(HatchPatternType.PreDefined, pattern); cs.AppendEntity(h); t.AddNewlyCreatedDBObject(h, true); h.Associative = true; h.HatchStyle = HatchStyle.Normal; // добавление контура полилинии в гштриховку var ids = new ObjectIdCollection(); ids.Add(loop.Id); try { h.AppendLoop(HatchLoopTypes.Default, ids); } catch (Exception ex) { Logger.Log.Error(ex, $"CreateAssociativeHatch"); h.Erase(); return null; } h.EvaluateHatch(true); var orders = cs.DrawOrderTableId.GetObject(OpenMode.ForWrite) as DrawOrderTable; orders.MoveToBottom(new ObjectIdCollection(new[] { h.Id })); return h; }
public void Figura2() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite detalės spindulį"); double Spindulys; GetSpindulys.AllowNegative = false; GetSpindulys.AllowZero = false; GetSpindulys.AllowNone = false; PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys); Spindulys = GetSpindulysRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite centro tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); //Apskritimas Circle Apskritimas = new Circle(Taskas, new Vector3d(0, 0, 1), Spindulys); btr.AppendEntity(Apskritimas); tr.AddNewlyCreatedDBObject(Apskritimas, true); //Linijos Polyline3d polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); PolylineVertex3d vex3d = new PolylineVertex3d(); // Linija NR1 (centrine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 + Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2 - Spindulys / 6, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2 - Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR2 (virsutine) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 + Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2 - Spindulys / 5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y + Spindulys / 2 + Spindulys / 1.5, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); polyline = new Polyline3d(); btr.AppendEntity(polyline); tr.AddNewlyCreatedDBObject(polyline, true); // Linija NR3 (kaire) vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y + Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); vex3d = new PolylineVertex3d(new Point3d(Taskas.X - Spindulys / 2 - Spindulys / 2 - Spindulys / 4, Taskas.Y - Spindulys / 2, 0)); polyline.AppendVertex(vex3d); tr.AddNewlyCreatedDBObject(vex3d, true); //Apskritimas FIll Viduryje Circle ApskritimasFillMIni = new Circle(new Point3d(Taskas.X + Spindulys / 2, Taskas.Y - Spindulys / 2, 0), new Vector3d(0, 0, 1), Spindulys / 8); btr.AppendEntity(ApskritimasFillMIni); tr.AddNewlyCreatedDBObject(ApskritimasFillMIni, true); Hatch hatch = new Hatch(); btr.AppendEntity(hatch); tr.AddNewlyCreatedDBObject(hatch, true); ObjectIdCollection ID = new ObjectIdCollection(); ID.Add(ApskritimasFillMIni.ObjectId); hatch.HatchStyle = HatchStyle.Ignore; hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = true; hatch.AppendLoop(HatchLoopTypes.Outermost, ID); hatch.EvaluateHatch(true); //Trikampis Solid trikampis = new Solid(new Point3d(Taskas.X - Spindulys / 4, Taskas.Y, 0), new Point3d(Taskas.X, Taskas.Y + Spindulys / 6, 0), new Point3d(Taskas.X, Taskas.Y - Spindulys / 6, 0)); btr.AppendEntity(trikampis); tr.AddNewlyCreatedDBObject(trikampis, true); tr.Commit(); } }
/// <summary> /// Generates and adds a series of <see cref="Hatch"/> objects to the supplied <see cref="BlockTableRecord"/> /// </summary> /// <returns>The selected color as a<see cref="Autodesk.AutoCAD.Colors.Color"/></returns> private static void CreateHatchesForConcentricCircles(BlockTableRecord blockTableRecord, ObjectIdCollection objectIdCollection, Transaction transaction) { var rand = new Random(); var previousPattern = string.Empty; for (var i = 0; i < objectIdCollection.Count - 1; i++) { var r = Convert.ToByte((i + 1)*rand.Next(0, 25)); var g = Convert.ToByte((i + 1)*rand.Next(0, 25)); var b = Convert.ToByte((i + 1)*rand.Next(0, 25)); using (var hatch = new Hatch()) { blockTableRecord.AppendEntity(hatch); transaction.AddNewlyCreatedDBObject(hatch, true); var pattern = GetRandomHatchPatternName(); //ensure pattern isn't repeated by from previous hatch // in production quality code I would move this behavior to avoid violating SRP/SoC while (pattern.Equals(previousPattern, StringComparison.InvariantCultureIgnoreCase)) { pattern = GetRandomHatchPatternName(); } previousPattern = pattern; hatch.SetHatchPattern(HatchPatternType.PreDefined, pattern); hatch.Color = Color.FromRgb(r, g, b); // Associative must be set after the hatch object is appended to the block table record and before AppendLoop hatch.Associative = true; // Take the current circle and the next to create a HatchLoop hatch.AppendLoop(HatchLoopTypes.Outermost, new ObjectIdCollection {objectIdCollection[i]}); hatch.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection {objectIdCollection[i + 1]}); hatch.EvaluateHatch(true); } } }
public void CreateNewHatch(BlockTableRecord btr) { var h = new Hatch(); h.Annotative = AnnotativeStates.False; h.Layer = Layer; h.Color = Color; h.LineWeight = Lineweight; h.SetHatchPattern(PatternType, PatternName); h.PatternAngle = PatternAngle; h.PatternScale = PatternScale; h.SetHatchPattern(PatternType, PatternName); Id = btr.AppendEntity(h); btr.Database.TransactionManager.TopTransaction.AddNewlyCreatedDBObject(h, true); if (IdsAssociate != null && IdsAssociate.Count > 0) { h.Associative = true; h.AppendLoop(HatchLoopTypes.Default, IdsAssociate); h.EvaluateHatch(false); } }
private Hatch ParseHatch(ConfigNode node) { Vector3 position = Vector3.zero; Vector3 scale = Vector3.one; if (!node.HasValue("attachNodeId")) { Debug.LogWarning("[FreeIVA] Hatch attachNodeId not found: Skipping hatch."); return null; } Hatch hatch = new Hatch(); hatch.AttachNodeId = node.GetValue("attachNodeId"); if (node.HasValue("position")) { string posString = node.GetValue("position"); string[] p = posString.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries); if (p.Length != 3) { Debug.LogWarning("[FreeIVA] Invalid hatch position definition \"" + posString + "\": Must be in the form x, y, z."); return null; } else hatch.LocalPosition = new Vector3(float.Parse(p[0]), float.Parse(p[1]), float.Parse(p[2])); } else { Debug.LogWarning("[FreeIVA] Hatch position not found: Skipping hatch."); return null; } if (node.HasValue("scale")) { string scaleString = node.GetValue("scale"); string[] s = scaleString.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries); if (s.Length != 3) { Debug.LogWarning("[FreeIVA] Invalid hatch scale definition \"" + scaleString + "\": Must be in the form x, y, z."); return null; } else hatch.Scale = new Vector3(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2])); } else { Debug.LogWarning("[FreeIVA] Hatch scale not found: Skipping hatch."); return null; } if (node.HasValue("rotation")) { string rotationString = node.GetValue("rotation"); string[] s = rotationString.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries); if (s.Length != 3) { Debug.LogWarning("[FreeIVA] Invalid hatch rotation definition \"" + rotationString + "\": Must be in the form x, y, z."); return null; } else hatch.Rotation = Quaternion.Euler(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2])); } else { Debug.LogWarning("[FreeIVA] Hatch rotation not found: Skipping hatch."); return null; } if (node.HasNode("HideWhenOpen")) { ConfigNode[] hideNodes = node.GetNodes("HideWhenOpen"); foreach (var hideNode in hideNodes) { if (!hideNode.HasValue("name")) { Debug.LogWarning("[FreeIVA] HideWhenOpen name not found."); continue; } string propName = hideNode.GetValue("name"); Vector3 propPos; if (hideNode.HasValue("position")) { string posString = hideNode.GetValue("position"); string[] p = posString.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries); if (p.Length != 3) { Debug.LogWarning("[FreeIVA] Invalid HideWhenOpen position definition \"" + posString + "\": Must be in the form x, y, z."); continue; } else { propPos = new Vector3(float.Parse(p[0]), float.Parse(p[1]), float.Parse(p[2])); } } else { Debug.LogWarning("[FreeIVA] Hatch position not found: Skipping hatch."); continue; } hatch.HideWhenOpen.Add(new KeyValuePair<Vector3, string>(propPos, propName)); } } if (node.HasNode("InternalCollider")) { ConfigNode hatchColliderNode = node.GetNode("InternalCollider"); if (hatchColliderNode != null) hatch.Collider = ParseInternalCollider(hatchColliderNode); } return hatch; }
public void Figura4() { Database db = HostApplicationServices.WorkingDatabase; Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db); Editor ed = doc.Editor; PromptDoubleOptions GetSpindulys = new PromptDoubleOptions("\nĮveskite didžiausio apskritimo spindulį"); double Spindulys; GetSpindulys.AllowNegative = false; GetSpindulys.AllowZero = false; GetSpindulys.AllowZero = false; PromptDoubleResult GetSpindulysRezultatas = ed.GetDouble(GetSpindulys); Spindulys = GetSpindulysRezultatas.Value; PromptDoubleOptions GetPlotis = new PromptDoubleOptions("\nĮveskite apskirtimo spindulio mažėjimą"); double Plotis; GetPlotis.AllowNegative = false; GetPlotis.AllowZero = false; GetPlotis.AllowZero = false; PromptDoubleResult GetPlotisRezultatas = ed.GetDouble(GetPlotis); Plotis = GetPlotisRezultatas.Value; PromptPointOptions GetTaskas = new PromptPointOptions("\nPasirinkite centro tašką"); Point3d Taskas; GetTaskas.AllowNone = false; PromptPointResult GetTaskasRezultatas = ed.GetPoint(GetTaskas); Taskas = GetTaskasRezultatas.Value; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); int i = 1; while(Spindulys > 0) { Circle Apskritimas = new Circle(Taskas, new Vector3d(0, 0, 1), Spindulys); btr.AppendEntity(Apskritimas); tr.AddNewlyCreatedDBObject(Apskritimas, true); Hatch hatch = new Hatch(); btr.AppendEntity(hatch); tr.AddNewlyCreatedDBObject(hatch, true); ObjectIdCollection ID = new ObjectIdCollection(); ID.Add(Apskritimas.ObjectId); hatch.HatchStyle = HatchStyle.Ignore; hatch.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); hatch.Associative = true; hatch.AppendLoop(HatchLoopTypes.Outermost, ID); hatch.EvaluateHatch(true); hatch.ColorIndex = i++; Spindulys -= Plotis; } tr.Commit(); } }
private void сreateHatch(Extents3d extText, BlockTableRecord btr) { if (extText.Diagonal() < 100) { return; } // Отступ контура штриховки от границ текста Extents3d ext = new Extents3d(new Point3d(extText.MinPoint.X - 10, extText.MinPoint.Y - 10, 0), new Point3d(extText.MaxPoint.X + 10, extText.MaxPoint.Y + 10, 0)); var h = new Hatch(); h.SetDatabaseDefaults(btr.Database); if (!panelBtr.CaptionLayerId.IsNull) h.LayerId = panelBtr.CaptionLayerId; h.LineWeight = LineWeight.LineWeight015; h.Linetype = SymbolUtilityServices.LinetypeContinuousName; h.Color = Color.FromRgb(250, 250, 250); h.Transparency = new Transparency(80); h.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE"); h.PatternScale = 25.0; btr.AppendEntity(h); var t = btr.Database.TransactionManager.TopTransaction; t.AddNewlyCreatedDBObject(h, true); h.Associative = true; h.HatchStyle = HatchStyle.Normal; // Полилиния по контуру текста Polyline pl = new Polyline(); pl.SetDatabaseDefaults(btr.Database); pl.LineWeight = LineWeight.LineWeight015; pl.Linetype = SymbolUtilityServices.LinetypeContinuousName; pl.ColorIndex = 256; // ПоСлою if (!panelBtr.CaptionLayerId.IsNull) pl.LayerId = panelBtr.CaptionLayerId; pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0); pl.AddVertexAt(0, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0); pl.AddVertexAt(0, ext.MaxPoint.Convert2d(), 0, 0, 0); pl.AddVertexAt(0, new Point2d(ext.MinPoint.X, ext.MaxPoint.Y), 0, 0, 0); pl.Closed = true; ObjectId idPl = btr.AppendEntity(pl); t.AddNewlyCreatedDBObject(pl, true); // добавление контура полилинии в гштриховку var ids = new ObjectIdCollection(); ids.Add(idPl); h.AppendLoop(HatchLoopTypes.Default, ids); h.EvaluateHatch(true); // Замена текстов - чтобы они стали поверх штриховки. panelBtr.IdCaptionMarkSb = replaceText(panelBtr.IdCaptionMarkSb, btr); panelBtr.IdCaptionPaint = replaceText(panelBtr.IdCaptionPaint, btr); }