public override void ResolveReferences(Class374 modelBuilder) { base.ResolveReferences(modelBuilder); DxfEvalGraph evalGraph = this.Object as DxfEvalGraph; if (evalGraph.Nodes == null) { return; } int num = Class740.smethod_12(evalGraph.Nodes); for (int index = 0; index < num; ++index) { evalGraph.Nodes[index].Expression = modelBuilder.method_4 <DxfObject>(this.ExpressionHandles[index]); DxfObject expression = evalGraph.Nodes[index].Expression; } foreach (DxfEvalGraph.GraphNode node in evalGraph.Nodes) { if (node.Expression == null) { Class740.smethod_14(evalGraph); break; } } }
/// <summary> /// add entity to the given dxf object ( it can be Dxfdocument or Block ) /// optionally set layer /// </summary> public static EntityObject AddEntity(this DxfObject dxfObj, EntityObject eo, Layer layer = null) { if (dxfObj is DxfDocument) { (dxfObj as DxfDocument).AddEntity(eo); } else if (dxfObj is Block) { (dxfObj as Block).Entities.Add(eo); } else if (dxfObj is netDxf.Objects.Group) { (dxfObj as netDxf.Objects.Group).Entities.Add(eo); } else { throw new ArgumentException($"dxfObj must DxfDocument or Block"); } if (layer != null) { eo.Layer = layer; } return(eo); }
internal static DxfObjectsSection ObjectsSectionFromBuffer(DxfCodePairBufferReader buffer) { var objects = new List <DxfObject>(); objects.Clear(); while (buffer.ItemsRemain) { var pair = buffer.Peek(); if (DxfCodePair.IsSectionEnd(pair)) { // done reading objects buffer.Advance(); // swallow (0, ENDSEC) break; } if (pair.Code != 0) { throw new DxfReadException("Expected new object.", pair); } var obj = DxfObject.FromBuffer(buffer); if (obj != null) { objects.Add(obj); } } var section = new DxfObjectsSection(); section.Objects.AddRange(objects); return(section); }
/// <summary> /// add entity to the given dxf object ( it can be Dxfdocument or Block ) /// optionally set layer /// </summary> public static void AddEntities(this DxfObject dxfObj, IEnumerable <EntityObject> ents, Layer layer = null) { foreach (var ent in ents) { dxfObj.AddEntity(ent, layer); } }
/// <summary> /// Deletes a layout and removes the layout entities from the document. /// </summary> /// <param name="item"><see cref="Layout">Layout</see> to remove from the document.</param> /// <returns>True if the layout has been successfully removed, or false otherwise.</returns> /// <remarks>Reserved layouts or any other referenced by objects cannot be removed.</remarks> public override bool Remove(Layout item) { if (item == null) { return(false); } if (!this.Contains(item)) { return(false); } if (item.IsReserved) { return(false); } // remove the entities of the layout List <DxfObject> refObjects = this.GetReferences(item.Name); if (refObjects.Count != 0) { DxfObject[] entities = new DxfObject[refObjects.Count]; refObjects.CopyTo(entities); foreach (DxfObject e in entities) { this.Owner.RemoveEntity(e as EntityObject); } } // remove the associated block of the Layout that is being removed this.Owner.Blocks.References[item.AssociatedBlock.Name].Remove(item); this.Owner.Blocks.Remove(item.AssociatedBlock); item.AssociatedBlock = null; // remove the layout this.Owner.AddedObjects.Remove(item.Handle); this.list.Remove(item.Name); item.Handle = null; item.Owner = null; item.NameChanged -= this.Item_NameChanged; // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... int index = 0; foreach (Layout l in this.list.Values) { // rename the corresponding PaperSpace block if (l.IsPaperSpace) { string spaceName = index == 0 ? Block.PaperSpace.Name : string.Concat(Block.PaperSpace.Name, index - 1); l.AssociatedBlock.SetName(spaceName, false); index += 1; } } return(true); }
public static IEnumerable <Face3d> DrawCuboid(this BBox3D bbox, DxfObject dxfObj, Layer layer = null) { var ents = bbox.ToFace3DList().ToList(); dxfObj.AddEntities(ents, layer); return(ents); }
internal DictionaryObject(DxfObject owner) : base(DxfObjectCode.Dictionary) { this.isHardOwner = false; this.cloning = DictionaryCloningFlags.KeepExisting; this.entries = new Dictionary<string, string>(); this.Owner = owner; }
internal DictionaryObject(DxfObject owner) : base(DxfObjectCode.Dictionary) { this.isHardOwner = false; this.cloning = DictionaryCloningFlags.KeepExisting; this.entries = new Dictionary <string, string>(); this.owner = owner; }
/// <summary> /// Creates and add dxf entities for 6 faces of a cuboid /// </summary> public static IEnumerable <EntityObject> DrawCuboid(this DxfObject dxfObj, Vector3D center, Vector3D size, Layer layer = null) { var ents = DxfKit.Cuboid(center, size).ToList(); dxfObj.AddEntities(ents, layer); return(ents); }
private static void EnsureFileContainsObject(DxfObject obj, string text, DxfAcadVersion version = DxfAcadVersion.R12) { var file = new DxfFile(); file.Clear(); file.Header.Version = version; file.Objects.Add(obj); VerifyFileContains(file, text); }
/// <summary> /// Creates and add dxf entities for a 3 axis of given length centered in given center point. /// </summary> public static IEnumerable <EntityObject> DrawStar(this DxfObject dxfObj, Vector3D center, double L, Layer layer = null) { var q = DxfKit.Star(center, L).ToList(); foreach (var line in q) { dxfObj.AddEntity(line, layer); } return(q); }
public GraphNode( int id, DxfObject expression, int firstIncomingEdge, int lastIncomingEdge, int firstOutgoingEdge, int lastOutgoingEdge) { this.graphNodeId_0 = new DxfEvalGraph.GraphNodeId(id); this.int_0 = firstIncomingEdge; this.int_1 = lastIncomingEdge; this.int_2 = firstOutgoingEdge; this.int_3 = lastOutgoingEdge; this.Expression = expression; }
/// <summary> /// Deletes a layout and removes the layout entities from the document. /// </summary> /// <param name="item"><see cref="Layout">Layout</see> to remove from the document.</param> /// <returns>True if the layout has been successfully removed, or false otherwise.</returns> /// <remarks>Reserved layouts or any other referenced by objects cannot be removed.</remarks> public override bool Remove(Layout item) { if (item == null) { return(false); } if (!this.Contains(item)) { return(false); } if (item.IsReserved) { return(false); } // remove the entities of the layout List <DxfObject> refObjects = this.GetReferences(item.Name); if (refObjects.Count != 0) { DxfObject[] entities = new DxfObject[refObjects.Count]; refObjects.CopyTo(entities); foreach (DxfObject e in entities) { this.Owner.RemoveEntity(e as EntityObject); } } // remove the associated block of the Layout that is being removed this.Owner.Blocks.References[item.AssociatedBlock.Name].Remove(item); this.Owner.Blocks.Remove(item.AssociatedBlock); item.AssociatedBlock = null; // remove the layout this.Owner.AddedObjects.Remove(item.Handle); this.list.Remove(item.Name); item.Handle = null; item.Owner = null; item.NameChanged -= this.Item_NameChanged; this.RenameAssociatedBlocks(); return(true); }
internal void SetValue(DxfObject value, bool addPersistentReactor) { this.dxfObjectReference_0 = DxfObjectReference.GetReference((IDxfHandledObject)value); if (this.dxfObjectReference_0 == null) { return; } if (value is INamedObject) { this.string_0 = (string)null; } if (this.dxfDictionary_0 == null) { return; } this.dxfDictionary_0.method_10((IDictionaryEntry)this, addPersistentReactor); }
private static string GetName(DxfObject x) { var pName = x.GetType().GetProperty("Name"); if (pName != null) { return(pName.GetValue(x, null) as string); } var pValue = x.GetType().GetProperty("Value"); if (pValue != null) { return(pValue.GetValue(x, null) as string); } return(x.CodeName); }
internal void method_19() { if (this.ExtensionDictionary == null) { return; } DxfObject valueByName = this.ExtensionDictionary.GetValueByName("ACAD_MLATT"); if (!(valueByName is DxfXRecord)) { return; } DxfXRecordValueCollection values = ((DxfXRecord)valueByName).Values; if (values.Count <= 2) { return; } DxfXRecordValue dxfXrecordValue1 = values[2]; if (dxfXrecordValue1.Code != (short)70) { return; } int num = (int)(short)dxfXrecordValue1.Value; if (values.Count <= 2 + num) { return; } for (int index = 0; index < num; ++index) { DxfXRecordValue dxfXrecordValue2 = values[3 + index]; if (dxfXrecordValue2.Code != (short)340) { break; } DxfAttributeBase dxfAttributeBase = dxfXrecordValue2.Value as DxfAttributeBase; if (dxfAttributeBase != null) { dxfAttributeBase.dxfAttributeBase_0 = this; } } }
public void ResolveReferences(Class374 modelBuilder) { if (this.ulong_0 == 0UL) { return; } DxfObject dxfObject = modelBuilder.method_4 <DxfObject>(this.ulong_0); if (dxfObject == null || dxfObject.Reference == null || dxfObject.Reference.Value == null) { return; } INamedObject namedObject = dxfObject as INamedObject; if (namedObject != null && string.IsNullOrEmpty(namedObject.Name)) { namedObject.Name = this.dxfDictionaryEntry_0.Name; } this.dxfDictionaryEntry_0.SetValue(dxfObject); dxfObject.Accept((IObjectVisitor)modelBuilder.ObjectCollectionResolver); }
internal bool RemoveReactor(DxfObject o) { return this.reactors.Remove(o); }
protected DxfObject(string codename) { this.codename = codename; this.handle = null; this.owner = null; }
/// <summary> /// Deletes a layout and removes the layout entities from the document. /// </summary> /// <param name="layout"><see cref="Layout">Layout</see> to remove from the document.</param> /// <returns>True is the layout has been successfully removed, or false otherwise.</returns> /// <remarks>Reserved layouts or any other referenced by objects cannot be removed.</remarks> public override bool Remove(Layout layout) { if (layout == null) { return(false); } if (!this.Contains(layout)) { return(false); } if (layout.IsReserved) { return(false); } List <DxfObject> refObjects = this.references[layout.Name]; if (refObjects.Count != 0) { DxfObject[] entities = new DxfObject[refObjects.Count]; refObjects.CopyTo(entities); foreach (DxfObject e in entities) { this.document.RemoveEntity(e as EntityObject); } } // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... foreach (Layout l in this.list.Values) { // The ModelSpace block cannot be removed. if (l.IsPaperSpace) { this.document.Blocks.Remove(l.AssociatedBlock); l.AssociatedBlock = null; } } layout.Owner = null; layout.Viewport.Owner = null; this.document.AddedObjects.Remove(layout.Handle); this.references.Remove(layout.Name); this.list.Remove(layout.Name); // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... foreach (Layout l in this.list.Values) { // Create and add the corresponding PaperSpace block if (l.IsPaperSpace) { int index = this.list.Count - 3; string spaceName = index < 0 ? Block.PaperSpace.Name : string.Concat(Block.PaperSpace.Name, index); Block associatadBlock = new Block(spaceName, false); associatadBlock = this.document.Blocks.Add(associatadBlock); l.AssociatedBlock = associatadBlock; associatadBlock.Record.Layout = l; } } return(true); }
internal void AddReactor(DxfObject o) { this.reactors.Add(o); }
internal DxfMText method_21() { if (this.ExtensionDictionary != null) { DxfObject valueByName = this.ExtensionDictionary.GetValueByName("ACAD_MLATT"); if (valueByName is DxfXRecord) { DxfXRecord dxfXrecord = (DxfXRecord)valueByName; int num = 0; DxfXRecordValueCollection values = dxfXrecord.Values; while (num < values.Count) { DxfXRecordValue dxfXrecordValue = values[num++]; if (dxfXrecordValue.Code == (short)1 && "Embedded Object".Equals(dxfXrecordValue.Value.ToString())) { break; } } if (num < values.Count) { DxfXRecordValueCollection xrecordValueCollection = new DxfXRecordValueCollection(); xrecordValueCollection.AddRange((IEnumerable <DxfXRecordValue>) new DxfXRecordValue[5] { new DxfXRecordValue((short)0, (object)"MTEXT"), new DxfXRecordValue((short)100, (object)"AcDbEntity"), new DxfXRecordValue((short)8, (object)this.Layer.Name), new DxfXRecordValue((short)67, (object)(short)(this.PaperSpace ? 1 : 0)), new DxfXRecordValue((short)100, (object)"AcDbMText") }); while (num < values.Count) { xrecordValueCollection.Add(values[num++]); } Struct18 endGroup = new Struct18(0, (object)"ENDSIM"); DxfModel model = this.Model; if (model == null) { throw new Exception("Cannot get MTEXT substitute when attribute has no parent object."); } DxfMText dxfMtext = DxfReader.smethod_1(model, (Interface33) new Class720(endGroup, (IEnumerable <DxfXRecordValue>)xrecordValueCollection), endGroup) as DxfMText; if (dxfMtext != null) { dxfMtext.method_12((DxfEntity)this); dxfMtext.Style = this.Style; if (this.IsAnnotative) { dxfMtext.IsAnnotative = true; dxfMtext.vmethod_2((IDxfHandledObject)this); DxfDictionary dxfDictionary1 = DxfAnnotationScaleObjectContextData.smethod_7((DxfHandledObject)this, true); DxfDictionary dxfDictionary2 = DxfAnnotationScaleObjectContextData.smethod_7((DxfHandledObject)dxfMtext, true); foreach (IDictionaryEntry entry in (ActiveList <IDictionaryEntry>)dxfDictionary1.Entries) { dxfDictionary2.Entries.Add((IDictionaryEntry) new DxfDictionaryEntry("*A", (DxfObject)((DxfAttributeObjectContextData)entry.Value).Mtext)); } } return(dxfMtext); } } } } return((DxfMText)null); }
/// <summary> /// Initializes a new instance of the <c>DxfObject</c> class. /// </summary> /// <param name="codename">Object name.</param> protected DxfObject(string codename) { this.codename = codename; this.handle = null; this.owner = null; }
public DxfDictionaryEntry(string name, DxfObject value, bool valueReferenceIsHard) { this.string_0 = name; this.dxfObjectReference_0 = DxfObjectReference.GetReference((IDxfHandledObject)value); this.bool_0 = valueReferenceIsHard; }
public DxfDictionaryEntry(string name, DxfObject value) { this.string_0 = name; this.Value = value; }
internal void SetValue(DxfObject value) { this.SetValue(value, false); }
/// <summary> /// Initializes a new instance of the <c>EndSequence</c> class. /// </summary> public EndSequence(DxfObject owner) : base(DxfObjectCode.EndSequence) { this.Owner = owner; }
private static Geometry.Bounds GetBounds(DxfObject dxfObject) { if (dxfObject is MText mText) { return(NetDxfSizeCalculator.CalculateBounds( xLeft: (float)mText.Position.X, yBottom: (float)mText.Position.Y, isMText: true, text: mText.Value, // textHeightCache: mtext.Hei, // textWidthCache: GetDoubleValueOrNull(DxfPartKind.TextWidthCache), textWidth: (float)mText.RectangleWidth, fontHeight: (float)mText.Height, attachmentPoint: mText.AttachmentPoint )); } else if (dxfObject is Text text) { var bounds = NetDxfSizeCalculator.CalculateBounds( xLeft: (float)text.Position.X, yBottom: (float)text.Position.Y, isMText: false, text: text.Value, fontHeight: (float)text.Height ); bounds = GetTextAlignmentOffset(bounds, text.Alignment, text.Value); return(bounds); } else if (dxfObject is netDxf.Entities.Attribute attrib) { var bounds = NetDxfSizeCalculator.CalculateBounds( xLeft: (float)attrib.Position.X, yBottom: (float)attrib.Position.Y, // xLeft: attrib.AbsolutePosition.X + attrib.Definition.AbsolutePosition.X, // yBottom: attrib.AbsolutePosition.Y + attrib.Definition.AbsolutePosition.Y, // xLeft: attrib.Definition.AbsolutePosition.X, // yBottom: attrib.Definition.AbsolutePosition.Y, isMText: false, text: attrib.Value + "", fontHeight: (float)attrib.Height ); bounds = GetTextAlignmentOffset(bounds, attrib.Alignment, attrib.Value + ""); // Don't know why, but attrib needs extra Y // bounds = bounds.Translate(new System.Numerics.Vector2(0, bounds.YSize * 0.5)); return(bounds); } else if (dxfObject is AttributeDefinition attdef) { var bounds = NetDxfSizeCalculator.CalculateBounds( xLeft: (float)attdef.Position.X, yBottom: (float)attdef.Position.Y, isMText: false, text: attdef.Value + "", fontHeight: (float)attdef.Height ); bounds = GetTextAlignmentOffset(bounds, attdef.Alignment, attdef.Value + ""); // Don't know why, but attrib needs extra Y // bounds = bounds.Translate(new System.Numerics.Vector2(0, bounds.YSize * 0.5)); return(bounds); } throw new ArgumentException("Unknown Element"); }
public DxfDictionaryEntry(DxfObject value) { this.dxfObjectReference_0 = DxfObjectReference.GetReference((IDxfHandledObject)value); }
/// <summary> /// Initializes a new instance of the <c>BlockEnd</c> class. /// </summary> public EndBlock(DxfObject owner) : base(DxfObjectCode.BlockEnd) { this.Owner = owner; }
/// <summary> /// Deletes a layout and removes the layout entities from the document. /// </summary> /// <param name="item"><see cref="Layout">Layout</see> to remove from the document.</param> /// <returns>True if the layout has been successfully removed, or false otherwise.</returns> /// <remarks>Reserved layouts or any other referenced by objects cannot be removed.</remarks> public override bool Remove(Layout item) { if (item == null) { return(false); } if (!this.Contains(item)) { return(false); } if (item.IsReserved) { return(false); } // remove the entities of the layout List <DxfObject> refObjects = this.references[item.Name]; if (refObjects.Count != 0) { DxfObject[] entities = new DxfObject[refObjects.Count]; refObjects.CopyTo(entities); foreach (DxfObject e in entities) { this.Owner.RemoveEntity(e as EntityObject); } } // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... foreach (Layout l in this.list.Values) { // The ModelSpace block cannot be removed. if (l.IsPaperSpace) { this.Owner.Blocks.References[l.AssociatedBlock.Name].Remove(l); this.Owner.Blocks.Remove(l.AssociatedBlock); l.AssociatedBlock = null; } } // remove the layout this.Owner.AddedObjects.Remove(item.Handle); this.references.Remove(item.Name); this.list.Remove(item.Name); item.Handle = null; item.Owner = null; item.Viewport.Owner = null; item.NameChanged -= this.Item_NameChanged; // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... int index = 0; foreach (Layout l in this.list.Values) { // Create and add the corresponding PaperSpace block if (l.IsPaperSpace) { string spaceName = index == 0 ? Block.PaperSpace.Name : string.Concat(Block.PaperSpace.Name, index - 1); Block associatadBlock = this.Owner.Blocks.Add(new Block(spaceName, null, null, false)); this.Owner.Blocks.References[associatadBlock.Name].Add(l); l.AssociatedBlock = associatadBlock; associatadBlock.Record.Layout = l; index += 1; // we need to redefine the owner of the layout entities l.Viewport.Owner = l.AssociatedBlock; foreach (DxfObject o in this.references[l.Name]) { o.Owner = l.AssociatedBlock; } } } return(true); }
/// <summary> /// Deletes a layout and removes the layout entities from the document. /// </summary> /// <param name="layout"><see cref="Layout">Layout</see> to remove from the document.</param> /// <returns>True if the layout has been successfully removed, or false otherwise.</returns> /// <remarks>Reserved layouts or any other referenced by objects cannot be removed.</remarks> public override bool Remove(Layout layout) { if (layout == null) { return(false); } if (!this.Contains(layout)) { return(false); } if (layout.IsReserved) { return(false); } List <DxfObject> refObjects = this.references[layout.Name]; if (refObjects.Count != 0) { DxfObject[] entities = new DxfObject[refObjects.Count]; refObjects.CopyTo(entities); foreach (DxfObject e in entities) { this.document.RemoveEntity(e as EntityObject); } } // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... foreach (Layout l in this.list.Values) { // The ModelSpace block cannot be removed. if (l.IsPaperSpace) { // Debug.Assert(l.AssociatedBlock != null, String.Format("The layout {0} associated block cannot be null.", l.Name)); if (l.AssociatedBlock == null) { throw new System.IO.InvalidDataException(String.Format("The layout {0} associated block cannot be null.", l.Name)); } this.document.Blocks.References[l.AssociatedBlock.Name].Remove(l); this.document.Blocks.Remove(l.AssociatedBlock); l.AssociatedBlock = null; } } layout.Owner = null; layout.Viewport.Owner = null; this.document.AddedObjects.Remove(layout.Handle); this.references.Remove(layout.Name); this.list.Remove(layout.Name); // When a layout is removed we need to rebuild the PaperSpace block names, to follow the naming Paper_Space, Paper_Space0, Paper_Space1, ... int index = 0; foreach (Layout l in this.list.Values) { // Create and add the corresponding PaperSpace block if (l.IsPaperSpace) { string spaceName = index == 1 ? Block.PaperSpace.Name : string.Concat(Block.PaperSpace.Name, index - 2); Block associatadBlock = new Block(spaceName, false); associatadBlock = this.document.Blocks.Add(associatadBlock); this.document.Blocks.References[associatadBlock.Name].Add(l); l.AssociatedBlock = associatadBlock; associatadBlock.Record.Layout = l; } index += 1; } return(true); }
internal bool RemoveReactor(DxfObject o) { return(this.reactors.Remove(o)); }