private void LoadObjects(BitReader reader, DwgObjectCache objectCache) { AssertHandleType(Variables.BlockControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.BlockControlObjectHandle)); AssertHandleType(Variables.LayerControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.LayerControlObjectHandle)); AssertHandleType(Variables.StyleObjectControlHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.StyleObjectControlHandle)); AssertHandleType(Variables.LineTypeObjectControlHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.LineTypeObjectControlHandle)); AssertHandleType(Variables.ViewControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.ViewControlObjectHandle)); AssertHandleType(Variables.UcsControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.UcsControlObjectHandle)); AssertHandleType(Variables.ViewPortControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.ViewPortControlObjectHandle)); AssertHandleType(Variables.AppIdControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.AppIdControlObjectHandle)); AssertHandleType(Variables.DimStyleControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.DimStyleControlObjectHandle)); AssertHandleType(Variables.ViewPortEntityHeaderControlObjectHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.ViewPortEntityHeaderControlObjectHandle)); AssertHandleType(Variables.GroupDictionaryHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.GroupDictionaryHandle)); AssertHandleType(Variables.MLineStyleDictionaryHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.MLineStyleDictionaryHandle)); AssertHandleType(Variables.NamedObjectsDictionaryHandle, DwgHandleReferenceCode.SoftPointer, nameof(Variables.NamedObjectsDictionaryHandle)); AssertHandleType(Variables.PaperSpaceBlockRecordHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.PaperSpaceBlockRecordHandle)); AssertHandleType(Variables.ModelSpaceBlockRecordHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.ModelSpaceBlockRecordHandle)); AssertHandleType(Variables.ByLayerLineTypeHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.ByLayerLineTypeHandle)); AssertHandleType(Variables.ByBlockLineTypeHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.ByBlockLineTypeHandle)); AssertHandleType(Variables.ContinuousLineTypeHandle, DwgHandleReferenceCode.SoftOwner, nameof(Variables.ContinuousLineTypeHandle)); BlockHeaders = objectCache.GetObject <DwgBlockControlObject>(reader, Variables.BlockControlObjectHandle.HandleOrOffset); Layers = objectCache.GetObject <DwgLayerControlObject>(reader, Variables.LayerControlObjectHandle.HandleOrOffset); Styles = objectCache.GetObject <DwgStyleControlObject>(reader, Variables.StyleObjectControlHandle.HandleOrOffset); LineTypes = objectCache.GetObject <DwgLineTypeControlObject>(reader, Variables.LineTypeObjectControlHandle.HandleOrOffset); Views = objectCache.GetObject <DwgViewControlObject>(reader, Variables.ViewControlObjectHandle.HandleOrOffset); UCSs = objectCache.GetObject <DwgUCSControlObject>(reader, Variables.UcsControlObjectHandle.HandleOrOffset); ViewPorts = objectCache.GetObject <DwgViewPortControlObject>(reader, Variables.ViewPortControlObjectHandle.HandleOrOffset); AppIds = objectCache.GetObject <DwgAppIdControlObject>(reader, Variables.AppIdControlObjectHandle.HandleOrOffset); DimStyles = objectCache.GetObject <DwgDimStyleControlObject>(reader, Variables.DimStyleControlObjectHandle.HandleOrOffset); ViewPortEntityHeaders = objectCache.GetObject <DwgViewPortEntityHeaderControlObject>(reader, Variables.ViewPortEntityHeaderControlObjectHandle.HandleOrOffset); GroupDictionary = objectCache.GetObject <DwgDictionary>(reader, Variables.GroupDictionaryHandle.HandleOrOffset); MLineStyleDictionary = objectCache.GetObject <DwgDictionary>(reader, Variables.MLineStyleDictionaryHandle.HandleOrOffset); NamedObjectDictionary = objectCache.GetObject <DwgDictionary>(reader, Variables.NamedObjectsDictionaryHandle.HandleOrOffset); PaperSpaceBlockRecord = objectCache.GetObject <DwgBlockHeader>(reader, Variables.PaperSpaceBlockRecordHandle.HandleOrOffset); ModelSpaceBlockRecord = objectCache.GetObject <DwgBlockHeader>(reader, Variables.ModelSpaceBlockRecordHandle.HandleOrOffset); ByLayerLineType = objectCache.GetObject <DwgLineType>(reader, Variables.ByLayerLineTypeHandle.HandleOrOffset); ByBlockLineType = objectCache.GetObject <DwgLineType>(reader, Variables.ByBlockLineTypeHandle.HandleOrOffset); ContinuousLineType = objectCache.GetObject <DwgLineType>(reader, Variables.ContinuousLineTypeHandle.HandleOrOffset); CurrentViewPort = objectCache.GetObjectOrDefault <DwgViewPort>(reader, Variables.CurrentViewPortEntityHandle.HandleOrOffset); CurrentLayer = objectCache.GetObject <DwgLayer>(reader, Variables.CurrentLayerHandle.HandleOrOffset); TextStyle = objectCache.GetObject <DwgStyle>(reader, Variables.TextStyleHandle.HandleOrOffset); CurrentEntityLineType = objectCache.GetObject <DwgLineType>(reader, Variables.CurrentEntityLineTypeHandle.HandleOrOffset); DimensionStyle = objectCache.GetObject <DwgDimStyle>(reader, Variables.DimensionStyleHandle.HandleOrOffset); CurrentMultiLineStyle = objectCache.GetObject <DwgMLineStyle>(reader, Variables.CurrentMultiLineStyleHandle.HandleOrOffset); PaperSpaceCurrentUCS = objectCache.GetObjectOrDefault <DwgUCS>(reader, Variables.PaperSpaceCurrentUCSHandle.HandleOrOffset); CurrentUCS = objectCache.GetObjectOrDefault <DwgUCS>(reader, Variables.CurrentUCSHandle.HandleOrOffset); DimensionTextStyle = objectCache.GetObject <DwgStyle>(reader, Variables.DimensionTextStyleHandle.HandleOrOffset); }
public DwgDrawing() { FileHeader = new DwgFileHeader(DwgVersionId.Default, 0, 0, 0); Variables = new DwgHeaderVariables(); Classes = new List <DwgClassDefinition>(); var continuous = new DwgLineType("CONTINUOUS") { Description = "Solid line" }; var defaultLayer = new DwgLayer("0") { LineType = continuous }; var standardStyle = new DwgStyle("STANDARD"); var standardMLineStyle = DwgMLineStyle.GetDefaultMLineStyle(); BlockHeaders = new DwgBlockControlObject() { DwgBlockHeader.GetPaperSpaceBlockRecord(defaultLayer), DwgBlockHeader.GetModelSpaceBlockRecord(defaultLayer) }; Layers = new DwgLayerControlObject { defaultLayer }; Styles = new DwgStyleControlObject() { standardStyle }; LineTypes = new DwgLineTypeControlObject() { new DwgLineType("BYLAYER"), new DwgLineType("BYBLOCK"), continuous }; Views = new DwgViewControlObject(); UCSs = new DwgUCSControlObject(); ViewPorts = new DwgViewPortControlObject() { DwgViewPort.GetActiveViewPort() }; AppIds = new DwgAppIdControlObject() { DwgAppId.GetAcadAppId(), DwgAppId.GetAcadMLeaderVersionAppId() }; DimStyles = new DwgDimStyleControlObject() { DwgDimStyle.GetStandardDimStyle(standardStyle) }; ViewPortEntityHeaders = new DwgViewPortEntityHeaderControlObject(); GroupDictionary = new DwgDictionary(); MLineStyleDictionary = new DwgDictionary() { { standardMLineStyle.Name, standardMLineStyle } }; NamedObjectDictionary = new DwgDictionary(); PaperSpaceBlockRecord = BlockHeaders["*PAPER_SPACE"]; ModelSpaceBlockRecord = BlockHeaders["*MODEL_SPACE"]; ByLayerLineType = LineTypes["BYLAYER"]; ByBlockLineType = LineTypes["BYBLOCK"]; ContinuousLineType = LineTypes["CONTINUOUS"]; CurrentLayer = Layers["0"]; TextStyle = Styles["STANDARD"]; CurrentEntityLineType = LineTypes["BYBLOCK"]; DimensionStyle = DimStyles["STANDARD"]; CurrentMultiLineStyle = (DwgMLineStyle)MLineStyleDictionary["Standard"]; DimensionTextStyle = Styles["STANDARD"]; }