1+ using ACadSharp . IO . Templates ;
2+ using ACadSharp . Objects ;
3+ using ACadSharp . Objects . Evaluations ;
4+
5+ namespace ACadSharp . IO . DWG
6+ {
7+ internal partial class DwgObjectReader : DwgSectionIO
8+ {
9+ private void readBlock1PtParameter ( CadBlock1PtParameterTemplate template )
10+ {
11+ this . readBlockParameter ( template ) ;
12+
13+ //1010 1020 1030
14+ template . Block1PtParameter . Location = this . _mergedReaders . Read3BitDouble ( ) ;
15+ //170
16+ template . Block1PtParameter . Value170 = this . _mergedReaders . ReadBitShort ( ) ;
17+ //171
18+ template . Block1PtParameter . Value171 = this . _mergedReaders . ReadBitShort ( ) ;
19+ //93
20+ template . Block1PtParameter . Value93 = this . _mergedReaders . ReadBitLong ( ) ;
21+ }
22+
23+ private void readBlockElement ( CadBlockElementTemplate template )
24+ {
25+ this . readEvaluationExpression ( template ) ;
26+
27+ //300 name
28+ template . BlockElement . ElementName = this . _mergedReaders . ReadVariableText ( ) ;
29+ //98
30+ template . BlockElement . Value98 = this . _mergedReaders . ReadBitLong ( ) ;
31+ //99
32+ template . BlockElement . Value99 = this . _mergedReaders . ReadBitLong ( ) ;
33+ //1071
34+ template . BlockElement . Value1071 = this . _mergedReaders . ReadBitLong ( ) ;
35+ }
36+
37+ private CadTemplate readBlockGripLocationComponent ( )
38+ {
39+ BlockGripExpression gripExpression = new BlockGripExpression ( ) ;
40+ CadBlockGripExpressionTemplate template = new CadBlockGripExpressionTemplate ( gripExpression ) ;
41+
42+ this . readEvaluationExpression ( template ) ;
43+
44+ return template ;
45+ }
46+
47+ private void readBlockParameter ( CadBlockParameterTemplate template )
48+ {
49+ this . readBlockElement ( template ) ;
50+
51+ //280
52+ template . BlockParameter . Value280 = this . _mergedReaders . ReadBit ( ) ;
53+ //281
54+ template . BlockParameter . Value281 = this . _mergedReaders . ReadBit ( ) ;
55+ }
56+
57+ private CadTemplate readBlockRepresentationData ( )
58+ {
59+ BlockRepresentationData representation = new BlockRepresentationData ( ) ;
60+ CadBlockRepresentationDataTemplate template = new CadBlockRepresentationDataTemplate ( representation ) ;
61+
62+ this . readCommonNonEntityData ( template ) ;
63+
64+ representation . Value70 = this . _mergedReaders . ReadBitShort ( ) ;
65+ template . BlockHandle = this . handleReference ( ) ;
66+
67+ return template ;
68+ }
69+
70+ private CadTemplate readBlockVisibilityParameter ( )
71+ {
72+ BlockVisibilityParameter blockVisibilityParameter = new BlockVisibilityParameter ( ) ;
73+ CadBlockVisibilityParameterTemplate template = new CadBlockVisibilityParameterTemplate ( blockVisibilityParameter ) ;
74+
75+ this . readBlock1PtParameter ( template ) ;
76+
77+ //281
78+ blockVisibilityParameter . Value281 = this . _mergedReaders . ReadBit ( ) ;
79+ //301
80+ blockVisibilityParameter . Name = this . _mergedReaders . ReadVariableText ( ) ;
81+ //302
82+ blockVisibilityParameter . Description = this . _mergedReaders . ReadVariableText ( ) ;
83+ //missing bit?? 91 should be an int
84+ blockVisibilityParameter . Value91 = this . _mergedReaders . ReadBit ( ) ;
85+
86+ //DXF 93 Total entities count
87+ var totalEntitiesCount = this . _objectReader . ReadBitLong ( ) ;
88+ for ( int i = 0 ; i < totalEntitiesCount ; i ++ )
89+ {
90+ //331
91+ template . EntityHandles . Add ( this . handleReference ( ) ) ;
92+ }
93+
94+ //DXF 92 states count
95+ var nstates = this . _objectReader . ReadBitLong ( ) ;
96+ for ( int j = 0 ; j < nstates ; j ++ )
97+ {
98+ template . StateTemplates . Add ( this . readState ( ) ) ;
99+ }
100+
101+ return template ;
102+ }
103+
104+ private void readEvaluationExpression ( CadEvaluationExpressionTemplate template )
105+ {
106+ this . readCommonNonEntityData ( template ) ;
107+
108+ //AcDbEvalExpr
109+ var unknown = this . _objectReader . ReadBitLong ( ) ;
110+
111+ //98
112+ template . CadObject . Value98 = this . _objectReader . ReadBitLong ( ) ;
113+ //99
114+ template . CadObject . Value99 = this . _objectReader . ReadBitLong ( ) ;
115+
116+ //Code value
117+ short code = this . _mergedReaders . ReadBitShort ( ) ;
118+ if ( code > 0 )
119+ {
120+ var groupValue = GroupCodeValue . TransformValue ( code ) ;
121+ switch ( groupValue )
122+ {
123+ case GroupCodeValueType . Double :
124+ case GroupCodeValueType . ExtendedDataDouble :
125+ this . _mergedReaders . ReadBitDouble ( ) ;
126+ break ;
127+ default :
128+ throw new System . NotImplementedException ( $ "[EvaluationExpression] Code not implemented { groupValue } ") ;
129+ }
130+ }
131+
132+ //90
133+ template . CadObject . Id = this . _objectReader . ReadBitLong ( ) ;
134+ }
135+
136+ private CadBlockVisibilityParameterTemplate . StateTemplate readState ( )
137+ {
138+ CadBlockVisibilityParameterTemplate . StateTemplate template = new CadBlockVisibilityParameterTemplate . StateTemplate ( ) ;
139+
140+ template . State . Name = this . _textReader . ReadVariableText ( ) ;
141+
142+ //DXF 94 subset count 1
143+ int n1 = this . _objectReader . ReadBitLong ( ) ;
144+ for ( int i = 0 ; i < n1 ; i ++ )
145+ {
146+ //332
147+ template . EntityHandles . Add ( this . handleReference ( ) ) ;
148+ }
149+
150+ //DXF 95 subset count 2
151+ var n2 = this . _objectReader . ReadBitLong ( ) ;
152+ for ( int i = 0 ; i < n2 ; i ++ )
153+ {
154+ //333
155+ template . ExpressionHandles . Add ( this . handleReference ( ) ) ;
156+ }
157+
158+ return template ;
159+ }
160+ }
161+ }
0 commit comments