public void AddToExport(ref StringBuilder _sb) { if (_sb == null) { return; } string tmp = string.Empty; _sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 _sb.AppendLine(DXFUtils.GV_MATERIAL); // GV_MATERIAL _sb.AppendLine(((int)EntitySaveCode.CLASS_NAME).ToString()); // 100 (subclass marker) _sb.AppendLine(this.GetType().ToString()); // GeometryViewer.ComponentInteraction.Material _sb.AppendLine(((int)EntitySaveCode.ENTITY_ID).ToString()); // 900 (custom code) _sb.AppendLine(this.ID.ToString()); // e.g. 254 _sb.AppendLine(((int)MaterialSaveCode.ID).ToString()); // 1301 _sb.AppendLine(this.ID.ToString()); _sb.AppendLine(((int)MaterialSaveCode.Name).ToString()); // 1302 _sb.AppendLine(this.Name); _sb.AppendLine(((int)MaterialSaveCode.THICKNESS).ToString()); // 1303 _sb.AppendLine(DXFUtils.ValueToString(this.Thickness, "F8")); _sb.AppendLine(((int)MaterialSaveCode.POSITION).ToString()); // 1304 _sb.AppendLine(Material.MPTWAP2String(this.Position)); _sb.AppendLine(((int)MaterialSaveCode.ACC_AREA).ToString()); // 1305 _sb.AppendLine(DXFUtils.ValueToString(this.AccArea, "F8")); tmp = (this.IsBound2CR) ? "1" : "0"; _sb.AppendLine(((int)MaterialSaveCode.IS_BOUND_2CR).ToString()); // 1306 _sb.AppendLine(tmp); _sb.AppendLine(((int)MaterialSaveCode.BOUND_CRID).ToString()); // 1307 _sb.AppendLine(this.BoundCRID.ToString()); _sb.AppendLine(((int)MaterialSaveCode.NR_ASSOC_SURFACES).ToString()); // 1308 _sb.AppendLine(this.NrSurfaces.ToString()); }
public virtual void AddToExport(ref StringBuilder _sb, bool _with_contained_entites) { if (_sb == null) { return; } string tmp = string.Empty; // THE FOLLOWING 4 LINES ARE TO BE CALLED IN EACH NON-ABSTRACT SUBCLASS TO REFLECT THE DYNAMIC TYPE // =============================================================================================== //_sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 //_sb.AppendLine(DXFUtils.GV_ENTITY); // GV_ENTITY //_sb.AppendLine(((int)EntitySaveCode.CLASS_NAME).ToString()); // 100 (subclass marker) //_sb.AppendLine(this.GetType().ToString()); // GeometryViewer.EntityGeometry.Entity // =============================================================================================== // GENERAL _sb.AppendLine(((int)EntitySaveCode.ENTITY_ID).ToString()); // 900 (custom code) _sb.AppendLine(this.ID.ToString()); // e.g. 254 _sb.AppendLine(((int)EntitySaveCode.ENTITY_NAME).ToString()); // 2 _sb.AppendLine(this.EntityName); // e.g. "Entity 254" _sb.AppendLine(((int)EntitySaveCode.VISIBILITY).ToString()); // 60 _sb.AppendLine(this.Visibility2SaveCode().ToString()); // (0 = visible, 1 = invisible; custom: 2 = half, -11 = unknown) _sb.AppendLine(((int)EntitySaveCode.SPACE).ToString()); // 67 _sb.AppendLine("0"); // (absent or 0 = entity in model space, 1 = entity in paper space, default = 0) _sb.AppendLine(((int)DXFSpecSaveCodes.COLOR_INDEX).ToString()); // 62 DXFImportExport.DXFColor dxf_color = new DXFImportExport.DXFColor((float)this.EntityColor.R, (float)this.EntityColor.G, (float)this.EntityColor.B, (float)this.EntityColor.A, true); int ic = DXFImportExport.DXFColor.DXFColor2Index(dxf_color); _sb.AppendLine(ic.ToString()); _sb.AppendLine(((int)EntitySaveCode.TRUECOLOR).ToString()); // 420 long tc = DXFImportExport.DXFColor.DXFColor2TrueColor(dxf_color); _sb.AppendLine(tc.ToString()); // 195(0..255)(0..255)(0..255) // SPECIFIC tmp = (this.IsValid) ? "1" : "0"; _sb.AppendLine(((int)EntitySpecificSaveCode.VALIDITY).ToString()); // 1001 _sb.AppendLine(tmp); // 1 = valid, 0 = invalid tmp = (this.AssociatedWComp) ? "1" : "0"; _sb.AppendLine(((int)EntitySpecificSaveCode.ASSOC_W_OTHER).ToString()); // 1002 _sb.AppendLine(tmp); // 1 = associated, 0 = not associated // ---CONTAINED ENTITIES START--- // ------------------------------ if (this.ContainedEntities == null || this.ContainedEntities.Count == 0 || !_with_contained_entites) { _sb.AppendLine(((int)EntitySpecificSaveCode.CONTAINED_ENTITIES).ToString()); // 1003 _sb.AppendLine("0"); } else { _sb.AppendLine(((int)EntitySpecificSaveCode.CONTAINED_ENTITIES).ToString()); // 1003 _sb.AppendLine(this.ContainedEntities.Count.ToString()); _sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 _sb.AppendLine(DXFUtils.ENTITY_SEQUENCE); // ENTSEQ foreach (Entity e in this.ContainedEntities) { if (e != null) { e.AddToExport(ref _sb, _with_contained_entites); } } _sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 _sb.AppendLine(DXFUtils.SEQUENCE_END); // SEQEND _sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 _sb.AppendLine(DXFUtils.ENTITY_CONTINUE); // ENTCTN } // ------------------------------ // ---CONTAINED ENTITIES END --- // ARC properties _sb.AppendLine(((int)EntitySpecificSaveCode.VISLINE_THICKNESS).ToString()); // 1004 _sb.AppendLine(DXFUtils.ValueToString(this.LineThicknessGUI, "F8")); // "0.25" foreach (string line in this.Text) { if (string.IsNullOrEmpty(line)) { continue; } _sb.AppendLine(((int)EntitySpecificSaveCode.TEXT_LINE).ToString()); // 1005 _sb.AppendLine(line); } // BPH properties tmp = (this.IsTopClosure) ? "1" : "0"; _sb.AppendLine(((int)EntitySpecificSaveCode.IS_TOP_CLOSURE).ToString()); // 1006 _sb.AppendLine(tmp); tmp = (this.IsBottomClosure) ? "1" : "0"; _sb.AppendLine(((int)EntitySpecificSaveCode.IS_BOTTOM_CLOSURE).ToString()); // 1007 _sb.AppendLine(tmp); // signify end of complex entity _sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString()); // 0 _sb.AppendLine(DXFUtils.SEQUENCE_END); // SEQEND }