Adding SPLINE to DXF makes the file corrupt (content not shown) - freepascal

I am working on my own DXF writer because I only need certain elements (such as LINE, POLYLINE, POINT an SPLINE).
I started with tfpdxfbridge and the idea was to include SPLINE support too. When I tried to manually add SPLINE to ENTITIES in the *.dxf file, the file is not opened anymore. Example of SPLINE:
SPLINE
5
274
330
1F
100
AcDbEntity
8
0
100
AcDbSpline
210
0.0
220
0.0
230
1.0
70
8
71
3
72
9
73
5
74
0
42
0.0000000001
43
0.0000000001
40
0.0
40
0.0
40
0.0
40
0.0
40
1.0
40
2.0
40
2.0
40
2.0
40
2.0
10
747.2822841342859
20
1453.676625339077
30
0.0
10
1364.898523055965
20
2324.178049512178
30
0.0
10
2830.924436828291
20
1999.364085075557
30
0.0
10
1130.854480067877
20
862.5152127789023
30
0.0
10
2837.42565094653
20
791.0561394394999
30
0.0
0
Does anybody know what the problem might be or how to make the file work again?
Here is the full file generated with tfpdxfbridge (except the SPLINE part, obviously).
0
SECTION
2
HEADER
999
Generator: TFPDxfWriteBridge
999
By jmpessoa#hotmail.com
9
$DIMASZ
40
0.1800
9
$DIMTSZ
40
0
9
$DIMGAP
40
0.0900
9
$DIMEXO
40
0.0625
9
$DIMDLI
40
0.38
9
$DIMDLE
40
0.0
9
$DIMEXE
40
0.1800
9
$DIMTXT
40
0.1800
9
$DIMTXTDIRECTION
70
0
9
$DIMTIH
70
1
9
$DIMTAD
70
0
9
$DIMCLRD
70
256
9
$DIMCLRE
70
256
9
$DIMCLRT
70
256
9
$DIMASO
70
1
9
$DIMASSOC
280
2
9
$DIMSHO
70
0
9
$DIMLUNIT
70
2
9
$DIMDEC
70
4
9
$DIMADEC
70
2
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
20
0.0
9
$EXTMAX
10
3200.0
20
3200.0
9
$LINMIN
10
0.0
20
0.0
9
$LINMAX
10
3200.0
20
3200.0
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
70
8
100
AcDbSymbolTable
100
AcDbLTypeTable
0
LTYPE
2
CONTINUOUS
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____________
72
65
73
0
40
0.000
70
0
0
LTYPE
2
HIDDEN
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
LTYPE
2
CENTER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ _ ____ _
72
65
73
4
40
2.000
49
1.250
49
-0.250
49
0.250
49
-0.250
70
0
0
LTYPE
2
DOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
. . . . .
72
65
73
2
40
0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DASHDOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ . __ .
72
65
73
4
40
1.000
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DIVIDE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ . . ____ . .
72
65
73
6
40
1.250
49
0.500
49
-0.250
49
0.000
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
BORDER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ . __ __ .
72
65
73
6
40
1.750
49
0.500
49
-0.250
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
MJLINE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
ENDTAB
0
TABLE
2
STYLE
70
2
100
AcDbSymbolTable
100
AcDbStyleTable
0
STYLE
2
DEFAULT
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
ARIAL.TTF
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
STYLE
2
ISOCPEUR
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
isocpeur.ttf
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
ENDTAB
0
TABLE
2
LAYER
70
9
100
AcDbSymbolTable
100
AcDbLayerTable
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
0
70
0
62
7
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
HIDDEN_YELLOW
70
0
62
2
6
HIDDEN
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CENTER_RED
70
0
62
1
6
CENTER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DOT_GREEN
70
0
62
3
6
DOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DASHDOT_CYAN
70
0
62
4
6
DASHDOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DIVIDE_BLUE
70
0
62
5
6
DIVIDE
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
BORDER_MAGENTA
70
0
62
6
6
BORDER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CONTINUOUS_GRAY
70
0
62
8
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
MYLAYER
70
0
62
5
6
MJLINE
0
ENDTAB
0
TABLE
2
DIMSTYLE
70
2
100
AcDbSymbolTable
100
AcDbDimStyleTable
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
GENERIC
70
0
77
0
176
256
177
256
178
256
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
CUSTOM
70
0
77
0
176
3
177
3
178
3
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
ENDSEC
0
SECTION
2
ENTITIES
0
CIRCLE
100
AcDbEntity
8
BORDER_MAGENTA
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
6.00
20
4.00
30
0.00
40
1.20
0
ARC
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
10.00
20
6.00
30
0.00
40
1.20
100
AcDbArc
50
10.00
51
80.00
0
POLYLINE
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
100
AcDb2dPolyline
70
0
66
1
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
0.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
1.50
20
1.50
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
0.00
30
0.0
0
SEQEND
0
POLYLINE
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
100
AcDb2dPolyline
70
1
66
1
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
-1.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
4.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
5.00
20
-3.00
30
0.0
0
SEQEND
0
ENDSEC
0
EOF

When I try to recover your DXF file I get the following:
Unknown header variable $LINMAX ignored on line 116.
Undefined group code 330 for object on line 1018.
Invalid or incomplete DXF input -- drawing discarded.
In your DXF you have:
330
1F
I see that 330 is included when I do my own spline and save as DXF. But, 330 is according to the documents:
Soft-pointer ID/handle to owner dictionary (optional)
This DXF will recover without any errors:
https://pastebin.com/KRpzCd4M
Perhaps you can do a comparison.

Related

An sdf file that I produce doesn't get accepted by a converter

I made a program that converts csv files into sdf files. Those files were supposed to go in another converter that turns them into something called a "Nist MS Library". The problem is that my file doesn't get accepted by the converter for "No spectra have been converted" and I don't understand why.
The files seem identical to me and I think I'm missing something about the specific file extension.
I'm really sorry if this doesn't belong here, I will delete the post if this is the case, but I really do not know where to ask.
I tried to make the "mass spectral peaks" integer, floats, delete them and put some values that I knew for sure that were accepted by the Nist converter, but nothing seems to work.
I will put 2 molecules, the first one is mine, the one that doesn't get accepted, the other one is the one that is fine for the program.
Coumarin
No Structure
0 0 0 0 0 0 0 0 0 0 0
> <NAME>
Coumarin
> <INCHIKEY>
> <FORMULA>
> <MW>
> <CASNO>
91645
> <ID>
2
> <COMMENT>
SAFC Cat. n. W526509\nColumn: SLB-5ms part#28471-U; Supelcowax-10 part#24079; Equity-1 part#28046-U;\nwww.sigmaaldrich.com |RI:1438|
> <SYNONYMS>
Coumarin
> <NUM PEAKS>
140
> <MASS SPECTRAL PEAKS>
39 1
39 233
40 38
40 0
40 0
41 0
41 1
41 5
42 2
42 2
43 35
43 0
43 12
44 26
45 20
45 67
46 7
46 4
46 2
46 1
47 0
48 4
49 32
49 3
50 5
50 166
51 183
52 20
53 35
54 7
55 1
56 0
58 0
59 2
59 23
60 6
60 11
61 89
62 213
63 503
64 164
64 13
65 15
65 7
66 9
68 4
71 0
71 1
72 2
73 1
73 19
74 0
74 32
75 39
76 14
77 11
77 1
78 0
78 0
79 0
79 9
79 0
80 2
80 1
81 0
81 0
81 1
82 0
82 0
83 0
83 0
84 6
84 0
85 17
86 2
86 2
87 28
88 7
89 523
90 581
91 25
91 48
92 40
92 36
93 4
93 5
94 1
94 0
97 2
98 6
98 0
99 2
99 0
100 0
100 1
101 5
102 3
103 0
103 0
103 0
104 0
105 0
105 0
106 0
106 0
106 0
107 0
108 0
109 0
110 0
110 0
111 0
111 0
112 0
112 0
113 0
116 0
117 6
117 0
118 1000
119 94
120 34
120 10
121 4
121 0
122 0
122 0
131 0
135 0
145 1
146 0
146 547
147 58
148 5
183 0
246 0
334 0
351 0
359 0
382 0
> <RI value>
1430.1
$$$$
ETHYL HYDROSULFIDE
(C) 2015 John Wiley & Sons, Inc.
CAS rn = 75081, Library ID = 1
3 2 0 0 0 0 0 0 0 0999 V2000
0.0000 0.2061 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7146 -0.2061 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
-0.7146 -0.2061 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
M END
> <NAME>
Ethyl hydrosulfide
> <SYNONYMS>
Ethanethiol
$:28DNJIEGIFACGWOD-UHFFFAOYSA-N
$:29n=703/0/1 p=620/0/1
> <FORMULA>
C2H6S
> <MW>
62
> <CASNO>
75081
> <ID>
1
> <COMMENT>
WileyID="LM_FFNSC3_1" RI1="703 (SLB-5MS (Hydro))" RI2="392 (SLB-5MS (FAMEs))" RI3="620 (Supelcowax-10 (FAMEs)" RI4="568 (Supelcowax-10 (FAEEs)" Contributor="Prof. L. Mondello (Chromaleont s.r.l./Univ. Messina, Italy)"
> <NUM PEAKS>
21
> <MASS SPECTRAL PEAKS>
44 20
45 235
46 147
47 727
48 20
49 32
50 2
51 2
52 2
53 2
54 2
55 2
56 16
57 84
58 115
59 84
60 16
61 155
62 999
63 36
64 44
$$$$

mysql return 360 degrees returned with strengths

I have a table of wind directions and strengths over a 24 hour period, sample data at the bottom of this question.
only directions that have strengths are stored in the database, I'm currently using the following SQL:
SELECT winddirection, avespeed
FROM wp_weather_data
WHERE ID%10 = 0
what I would like to return is an entry for every degree (0 value for any degree not in the db) and where there are multiple entries for a given degree to only return the highest value. Oh, and they need to be in ascending order of degrees.
Is this possible?
This is so I can plot a wind distribution chart on a polar chat plugin in WordPress.
sample data returned from the above sql:
294 2
271 3
269 2
285 3
289 2
123 1
130 1
144 1
160 0
168 0
161 0
135 0
138 0
331 0
115 0
136 0
161 0
267 0
114 0
265 0
204 0
248 1
206 0
199 1
250 2
244 3
257 3
272 5
267 5
208 3
221 3
223 4
253 6
233 5

prize distribution on the basis of rank using mysql

I have two tables one is prize table and one is result table
PRIZE TABLE
pm_id pm_fromrank pm_torank pm_prize pool_id
1 1 1 1000 72
2 2 5 500 72
3 6 10 270 72
RESULT TABLE have 3 type of ranks case
1st CASE
rs_id rs_userid rs_rank rs_poolid
1 131 1 72
2 132 1 72
3 133 2 72
4 134 3 72
5 135 4 72
6 136 5 72
7 137 6 72
8 138 6 72
9 139 7 72
10 140 8 72
11 141 9 72
12 142 10 72
2ND CASE
rs_id rs_userid rs_rank rs_poolid
1 131 1 72
2 132 2 72
3 133 3 72
4 134 4 72
5 135 5 72
6 136 6 72
7 137 7 72
8 138 8 72
9 139 9 72
10 140 10 72
11 141 11 72
12 142 12 72
3RD CASE
rs_id rs_userid rs_rank rs_poolid
1 131 1 72
2 132 2 72
3 133 3 72
4 134 4 72
5 135 5 72
6 136 6 72
7 137 7 72
8 138 8 72
9 139 9 72
10 140 10 72
11 141 10 72
12 142 10 72
now i have to distribute price only first 10 user in ascending order in following ways
1ST CASE PRIZE DISTRIBUTION
rs_id rs_userid rs_rank rs_poolid pricemoney
1 131 1 72 750
2 132 1 72 750
3 133 2 72 500
4 134 3 72 500
5 135 4 72 500
6 136 5 72 270
7 137 6 72 270
8 138 6 72 270
9 139 7 72 270
10 140 8 72 270
11 141 9 72 0
12 142 10 72 0
2ND CASE PRIZE DISTRIBUTION
rs_id rs_userid rs_rank rs_poolid pricemoney
1 131 1 72 1000
2 132 2 72 500
3 133 3 72 500
4 134 4 72 500
5 135 5 72 500
6 136 6 72 270
7 137 7 72 270
8 138 8 72 270
9 139 9 72 270
10 140 10 72 270
11 141 11 72 0
12 142 12 72 0
3RD CASE PRIZE DISTRIBUTION
rs_id rs_userid rs_rank rs_poolid pricemoney
1 131 1 72 1000
2 132 2 72 500
3 133 3 72 500
4 134 4 72 500
5 135 5 72 500
6 136 6 72 270
7 137 7 72 270
8 138 8 72 270
9 139 9 72 270
10 140 10 72 90
11 141 10 72 90
12 142 10 72 90
NOTE:- THE PRIZE TABLE AND RESULT TABLE HAVE RELATIONSHIP WITH POOL_ID
I have to find the prize distribution on the basis of rank using mysql and codeignitor
The solution for MySQL version 8+:
WITH
cte1 AS (SELECT *,
ROW_NUMBER() OVER (ORDER BY rs_rank, rs_id) rn,
DENSE_RANK() OVER (ORDER BY rs_rank) drnk
FROM result
ORDER BY rs_rank, rs_id LIMIT 10),
cte2 AS (SELECT cte1.drnk, SUM(prize.pm_prize) totalmoney
FROM cte1
JOIN prize ON cte1.rn BETWEEN prize.pm_fromrank AND pm_torank
GROUP BY cte1.drnk),
cte3 AS (SELECT *,
DENSE_RANK() OVER (ORDER BY rs_rank) drnk
FROM result
ORDER BY rs_rank, rs_id),
cte4 AS (SELECT MAX(drnk) max_drnk
FROM cte1),
cte5 AS (SELECT rs_id, rs_rank, COUNT(*) OVER (PARTITION BY rs_rank) rank_count
FROM cte3
JOIN cte4 ON cte3.drnk <= cte4.max_drnk)
SELECT result.*, cte2.totalmoney / cte5.rank_count pricemoney
FROM cte5
JOIN result USING (rs_id)
JOIN cte2 ON result.rs_rank = cte2.drnk
fiddle with explanations.

Insert php multiple data into mysql

I have 1000+ customers. I require customer report.
Here debit = potato + onion + ginger. Credit is commission.Balance will be updated every time. It will be balance - debit and balance + credit alternatively.
Grocery data report is as: Data is filled through php form with mysql_fetch_array query. Here few customers are as sample. and few data fields.
id cus_id cus_name potato onion ginger debit credit balance
1 12 munna 10 25 28 63 0 37
2 16 anil 24 56 84 164 0 136
3 34 palash 17 47 51 115 0 85
4 45 dimpy 35 64 39 138 0 112
Table grocery before and after entering new data:
id cus_id cus_name potato onion ginger debit credit balance
1 12 munna 10 25 28 63 0 37
2 16 anil 24 56 84 164 0 136
3 34 palash 17 47 51 115 0 85
4 45 dimpy 35 64 39 138 0 112
5 12 munna 0 0 0 0 6 43
6 16 anil 0 0 0 0 16 152
7 34 palash 0 0 0 0 12 97
8 45 dimpy 0 0 0 0 14 126
My problem is :
I am unable to update balance column, cus_name wise and cus_id wise and insert all data into mysql database. Suggest me with mysql query.

Percentage by Row Group

I have a matrix with rows grouped by Dept (Department). I am trying to get the actual hours / required hours percentage in a column for each row group, but I can only get the total %, not the % by group. Ex:
I should get this:
Total Employee Req Hrs Rep Hrs % Billable hrs % NonBill Hrs % Time Off %
Dept A Total 672 680 101 575 85 140 21 8 1
Emp1 168 170 101 150 89 50 29 0 0
Emp2 168 165 98 120 71 20 12 8 4
Emp3 168 175 104 155 92 20 12 0 0
Emp4 168 170 101 150 89 50 29 0 0
Dept B Total 420 428 102 365 87 80 19 4 .1
Emp5 168 170 101 150 89 50 29 0 0
Emp6 84 84 98 60 71 10 12 4 4
Emp7 168 175 104 155 92 20 12 0 0
G Total 1092 1108 101 940 86 190 17 12 1
But I get this:
Total Employee Req Hrs Rep Hrs % Billable hrs % NonBill Hrs % Time Off %
Dept A Total 1684 1675 101 1250 86 225 17 12 1
Emp1 168 170 101 150 89 50 29 0 0
Emp2 168 165 98 120 71 20 12 8 4
Emp3 168 175 104 155 92 20 12 0 0
Emp4 168 170 101 150 89 50 29 0 0
Dept B Total 1092 1108 101 1250 86 225 17 12 1
Emp5 168 170 101 150 89 50 29 0 0
Emp6 84 84 98 60 71 10 12 4 4
Emp7 168 175 104 155 92 20 12 0 0
G Total 1092 1108 101 940 86 190 17 12 1
The totals are correct but the % is wrong.
I have several Datasets because the report only runs the department you are in, except for the VPs who can see all departments.
I Insert the percentage columns into the matrix and have tried several expressions with no results including:
=Fields!ActHrs.Value/Fields!ReqHrs.Value
=Sum(Fields!ActHrs.Value, "Ut_Query")/Sum(Fields!ReqHrs.Value, "Ut_Query")
=Sum(Fields!ActHrs.Value, "Ut_Query","Dept")/Sum(Fields!ReqHrs.Value,
"Ut_Query","Dept")
=Sum(Fields!ActHrs.Value,"Dept", "Ut_Query")/Sum(Fields!ReqHrs.Value,
"Dept","Ut_Query")
Plus more I can't even remember.
I tried creating new groups, and even a new matrix.
There must be a simple way to get the percentage by group but I have not found an answer on any of the interned boards.
OK, I figured this out, but it doesn't make much sense. If I try:
=Textbox29/TextBox28 I get error messages about undefined variables.
If I go the the textbox properties and rename the textboxes to Act and Req and use:
=Act/Req I get the right answer.