@mlightcad/data-model 1.15.23 → 1.15.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-model.cjs +12 -12
- package/lib/database/AcDbSysVarManager.d.ts.map +1 -1
- package/lib/database/AcDbSysVarManager.js +49 -1
- package/lib/database/AcDbSysVarManager.js.map +1 -1
- package/lib/database/AcDbSystemVariables.d.ts +19 -1
- package/lib/database/AcDbSystemVariables.d.ts.map +1 -1
- package/lib/database/AcDbSystemVariables.js +18 -0
- package/lib/database/AcDbSystemVariables.js.map +1 -1
- package/lib/dxf/AcDbDxfObjectsReader.d.ts.map +1 -1
- package/lib/dxf/AcDbDxfObjectsReader.js +22 -1
- package/lib/dxf/AcDbDxfObjectsReader.js.map +1 -1
- package/lib/entity/AcDbHatch.d.ts +7 -0
- package/lib/entity/AcDbHatch.d.ts.map +1 -1
- package/lib/entity/AcDbHatch.js +53 -13
- package/lib/entity/AcDbHatch.js.map +1 -1
- package/lib/object/AcDbGroup.d.ts +367 -4
- package/lib/object/AcDbGroup.d.ts.map +1 -1
- package/lib/object/AcDbGroup.js +686 -19
- package/lib/object/AcDbGroup.js.map +1 -1
- package/package.json +5 -5
package/lib/object/AcDbGroup.js
CHANGED
|
@@ -49,47 +49,148 @@ var __values = (this && this.__values) || function(o) {
|
|
|
49
49
|
};
|
|
50
50
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
51
51
|
};
|
|
52
|
+
import { AcCmColor } from '@mlightcad/common';
|
|
52
53
|
import { AcDbObject } from '../base/AcDbObject.js';
|
|
54
|
+
import { AcDbEntity } from '../entity/AcDbEntity.js';
|
|
55
|
+
import { AcDbObjectIterator } from '../misc/AcDbObjectIterator.js';
|
|
53
56
|
/**
|
|
54
|
-
* Nongraphical GROUP object (DXF GROUP).
|
|
57
|
+
* Nongraphical GROUP object (DXF GROUP / ObjectARX `AcDbGroup`).
|
|
55
58
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
59
|
+
* A group is an ordered, named persistent selection set of database entities.
|
|
60
|
+
* It does not own its members. The group **name** is the key in the
|
|
61
|
+
* `ACAD_GROUP` dictionary; DXF group code 300 stores the **description**.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* ObjectARX requires the group to be added to the group dictionary (so it has
|
|
65
|
+
* an object id) before members are appended.
|
|
58
66
|
*/
|
|
59
67
|
var AcDbGroup = /** @class */ (function (_super) {
|
|
60
68
|
__extends(AcDbGroup, _super);
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new group.
|
|
71
|
+
*
|
|
72
|
+
* @param description - Optional description (ObjectARX ctor first arg).
|
|
73
|
+
* @param selectable - Whether the group is selectable as a unit (default `true`).
|
|
74
|
+
*/
|
|
75
|
+
function AcDbGroup(description, selectable) {
|
|
76
|
+
if (description === void 0) { description = ''; }
|
|
77
|
+
if (selectable === void 0) { selectable = true; }
|
|
78
|
+
var _this = _super.call(this) || this;
|
|
79
|
+
/** Dictionary key name of this group (`ACAD_GROUP` entry). */
|
|
63
80
|
_this._name = '';
|
|
64
|
-
|
|
81
|
+
/** Group description (DXF group 300). */
|
|
82
|
+
_this._description = '';
|
|
83
|
+
/** True when this is an anonymous (`*A…`) group. */
|
|
84
|
+
_this._anonymous = false;
|
|
85
|
+
/** Whether the group can be selected as a unit. */
|
|
65
86
|
_this._selectable = true;
|
|
87
|
+
/** Soft-pointer member entity ids, in group order. */
|
|
66
88
|
_this._entityIds = [];
|
|
89
|
+
_this.description = description;
|
|
90
|
+
_this.selectable = selectable;
|
|
67
91
|
return _this;
|
|
68
92
|
}
|
|
69
93
|
Object.defineProperty(AcDbGroup.prototype, "name", {
|
|
94
|
+
/**
|
|
95
|
+
* Gets the dictionary key name of this group (`ACAD_GROUP` entry).
|
|
96
|
+
*
|
|
97
|
+
* @returns The group name.
|
|
98
|
+
*/
|
|
70
99
|
get: function () {
|
|
71
100
|
return this._name;
|
|
72
101
|
},
|
|
102
|
+
/**
|
|
103
|
+
* Sets the dictionary key name of this group.
|
|
104
|
+
*
|
|
105
|
+
* Prefer {@link setName} when the group is already stored in
|
|
106
|
+
* `database.objects.group`, so the dictionary key stays in sync.
|
|
107
|
+
*
|
|
108
|
+
* @param value - The new group name.
|
|
109
|
+
*/
|
|
73
110
|
set: function (value) {
|
|
74
111
|
this._name = value;
|
|
75
112
|
},
|
|
76
113
|
enumerable: false,
|
|
77
114
|
configurable: true
|
|
78
115
|
});
|
|
116
|
+
Object.defineProperty(AcDbGroup.prototype, "description", {
|
|
117
|
+
/**
|
|
118
|
+
* Gets the group description (DXF group 300).
|
|
119
|
+
*
|
|
120
|
+
* @returns The description string.
|
|
121
|
+
*/
|
|
122
|
+
get: function () {
|
|
123
|
+
return this._description;
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Sets the group description (DXF group 300).
|
|
127
|
+
*
|
|
128
|
+
* @param value - The new description.
|
|
129
|
+
*/
|
|
130
|
+
set: function (value) {
|
|
131
|
+
this._description = String(value !== null && value !== void 0 ? value : '');
|
|
132
|
+
},
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
});
|
|
79
136
|
Object.defineProperty(AcDbGroup.prototype, "unnamed", {
|
|
137
|
+
/**
|
|
138
|
+
* Gets whether this is an anonymous (`*A…`) group.
|
|
139
|
+
*
|
|
140
|
+
* @returns `true` when the group is anonymous.
|
|
141
|
+
*
|
|
142
|
+
* @deprecated Prefer {@link isAnonymous} / {@link setAnonymous}.
|
|
143
|
+
*/
|
|
144
|
+
get: function () {
|
|
145
|
+
return this._anonymous;
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Sets whether this is an anonymous group.
|
|
149
|
+
*
|
|
150
|
+
* @param value - `true` to mark the group anonymous.
|
|
151
|
+
*
|
|
152
|
+
* @deprecated Prefer {@link isAnonymous} / {@link setAnonymous}.
|
|
153
|
+
*/
|
|
154
|
+
set: function (value) {
|
|
155
|
+
this._anonymous = value;
|
|
156
|
+
},
|
|
157
|
+
enumerable: false,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(AcDbGroup.prototype, "anonymous", {
|
|
161
|
+
/**
|
|
162
|
+
* Gets whether this is an anonymous group.
|
|
163
|
+
*
|
|
164
|
+
* @returns `true` when the group is anonymous.
|
|
165
|
+
*/
|
|
80
166
|
get: function () {
|
|
81
|
-
return this.
|
|
167
|
+
return this._anonymous;
|
|
82
168
|
},
|
|
169
|
+
/**
|
|
170
|
+
* Sets whether this is an anonymous group.
|
|
171
|
+
*
|
|
172
|
+
* @param value - `true` to mark the group anonymous.
|
|
173
|
+
*/
|
|
83
174
|
set: function (value) {
|
|
84
|
-
this.
|
|
175
|
+
this._anonymous = value;
|
|
85
176
|
},
|
|
86
177
|
enumerable: false,
|
|
87
178
|
configurable: true
|
|
88
179
|
});
|
|
89
180
|
Object.defineProperty(AcDbGroup.prototype, "selectable", {
|
|
181
|
+
/**
|
|
182
|
+
* Gets whether the group can be selected as a unit.
|
|
183
|
+
*
|
|
184
|
+
* @returns `true` when the group is selectable.
|
|
185
|
+
*/
|
|
90
186
|
get: function () {
|
|
91
187
|
return this._selectable;
|
|
92
188
|
},
|
|
189
|
+
/**
|
|
190
|
+
* Sets whether the group can be selected as a unit.
|
|
191
|
+
*
|
|
192
|
+
* @param value - `true` to allow selecting the group as a unit.
|
|
193
|
+
*/
|
|
93
194
|
set: function (value) {
|
|
94
195
|
this._selectable = value;
|
|
95
196
|
},
|
|
@@ -97,42 +198,542 @@ var AcDbGroup = /** @class */ (function (_super) {
|
|
|
97
198
|
configurable: true
|
|
98
199
|
});
|
|
99
200
|
Object.defineProperty(AcDbGroup.prototype, "entityIds", {
|
|
201
|
+
/**
|
|
202
|
+
* Gets soft-pointer member entity ids, in group order.
|
|
203
|
+
*
|
|
204
|
+
* @returns A readonly view of member object ids.
|
|
205
|
+
*/
|
|
100
206
|
get: function () {
|
|
101
207
|
return this._entityIds;
|
|
102
208
|
},
|
|
209
|
+
/**
|
|
210
|
+
* Replaces the entire member id list.
|
|
211
|
+
*
|
|
212
|
+
* @param value - New ordered list of member object ids.
|
|
213
|
+
*/
|
|
103
214
|
set: function (value) {
|
|
104
215
|
this._entityIds = __spreadArray([], __read(value), false);
|
|
105
216
|
},
|
|
106
217
|
enumerable: false,
|
|
107
218
|
configurable: true
|
|
108
219
|
});
|
|
220
|
+
/**
|
|
221
|
+
* Appends one member id to the group.
|
|
222
|
+
*
|
|
223
|
+
* @param id - Object id of the entity to append.
|
|
224
|
+
*
|
|
225
|
+
* @deprecated Prefer {@link append}.
|
|
226
|
+
*/
|
|
109
227
|
AcDbGroup.prototype.addEntityId = function (id) {
|
|
110
|
-
this.
|
|
228
|
+
this.append(id);
|
|
111
229
|
};
|
|
112
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Returns whether this group is anonymous.
|
|
232
|
+
*
|
|
233
|
+
* Mirrors ObjectARX `AcDbGroup::isAnonymous`.
|
|
234
|
+
*
|
|
235
|
+
* @returns `true` when the group is anonymous.
|
|
236
|
+
*/
|
|
237
|
+
AcDbGroup.prototype.isAnonymous = function () {
|
|
238
|
+
return this._anonymous;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Marks this group as anonymous.
|
|
242
|
+
*
|
|
243
|
+
* Mirrors ObjectARX `AcDbGroup::setAnonymous`.
|
|
244
|
+
*/
|
|
245
|
+
AcDbGroup.prototype.setAnonymous = function () {
|
|
246
|
+
this._anonymous = true;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Returns whether the group is not accessible.
|
|
250
|
+
*
|
|
251
|
+
* Mirrors ObjectARX `AcDbGroup::isNotAccessible`. This port always returns
|
|
252
|
+
* `false` (inaccessible/proxy groups are not modeled).
|
|
253
|
+
*
|
|
254
|
+
* @returns Always `false`.
|
|
255
|
+
*/
|
|
256
|
+
AcDbGroup.prototype.isNotAccessible = function () {
|
|
257
|
+
return false;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Sets the group name and, when database-bound, renames its `ACAD_GROUP`
|
|
261
|
+
* dictionary entry to match.
|
|
262
|
+
*
|
|
263
|
+
* Mirrors ObjectARX `AcDbGroup::setName`.
|
|
264
|
+
*
|
|
265
|
+
* @param name - The new group name.
|
|
266
|
+
*/
|
|
267
|
+
AcDbGroup.prototype.setName = function (name) {
|
|
113
268
|
var e_1, _a;
|
|
269
|
+
var _b;
|
|
270
|
+
var next = String(name !== null && name !== void 0 ? name : '');
|
|
271
|
+
var dict = (_b = this.database) === null || _b === void 0 ? void 0 : _b.objects.group;
|
|
272
|
+
if (!dict) {
|
|
273
|
+
this._name = next;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// Prefer the in-memory name when it still matches the dict entry; otherwise
|
|
277
|
+
// scan for this object (e.g. setAt before name was assigned).
|
|
278
|
+
var currentKey;
|
|
279
|
+
if (this._name && dict.getAt(this._name) === this) {
|
|
280
|
+
currentKey = this._name;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
try {
|
|
284
|
+
for (var _c = __values(dict.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
285
|
+
var _e = __read(_d.value, 2), key = _e[0], existing = _e[1];
|
|
286
|
+
if (existing === this) {
|
|
287
|
+
currentKey = key;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
293
|
+
finally {
|
|
294
|
+
try {
|
|
295
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
296
|
+
}
|
|
297
|
+
finally { if (e_1) throw e_1.error; }
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (currentKey === next) {
|
|
301
|
+
this._name = next;
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
// Do not overwrite another group; leave `_name` unchanged on collision.
|
|
305
|
+
var conflict = next ? dict.getAt(next) : undefined;
|
|
306
|
+
if (conflict && conflict !== this)
|
|
307
|
+
return;
|
|
308
|
+
if (currentKey != null && currentKey !== next) {
|
|
309
|
+
dict.remove(currentKey);
|
|
310
|
+
if (next)
|
|
311
|
+
dict.setAt(next, this);
|
|
312
|
+
}
|
|
313
|
+
this._name = next;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Returns the number of member entities in the group.
|
|
317
|
+
*
|
|
318
|
+
* Mirrors ObjectARX `AcDbGroup::numEntities`.
|
|
319
|
+
*
|
|
320
|
+
* @returns Member count.
|
|
321
|
+
*/
|
|
322
|
+
AcDbGroup.prototype.numEntities = function () {
|
|
323
|
+
return this._entityIds.length;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Copies all member object ids into `out` (when provided) and returns the
|
|
327
|
+
* member count.
|
|
328
|
+
*
|
|
329
|
+
* Mirrors ObjectARX `AcDbGroup::allEntityIds`.
|
|
330
|
+
*
|
|
331
|
+
* @param out - Optional array cleared and filled with member ids.
|
|
332
|
+
* @returns The number of member ids.
|
|
333
|
+
*/
|
|
334
|
+
AcDbGroup.prototype.allEntityIds = function (out) {
|
|
335
|
+
if (out) {
|
|
336
|
+
out.length = 0;
|
|
337
|
+
out.push.apply(out, __spreadArray([], __read(this._entityIds), false));
|
|
338
|
+
}
|
|
339
|
+
return this._entityIds.length;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Returns whether the group contains the given entity or object id.
|
|
343
|
+
*
|
|
344
|
+
* Mirrors ObjectARX `AcDbGroup::has`.
|
|
345
|
+
*
|
|
346
|
+
* @param entityOrId - An {@link AcDbEntity} or an object id string.
|
|
347
|
+
* @returns `true` when the id is a member of this group.
|
|
348
|
+
*/
|
|
349
|
+
AcDbGroup.prototype.has = function (entityOrId) {
|
|
350
|
+
var _a;
|
|
351
|
+
var id = typeof entityOrId === 'string' ? entityOrId : ((_a = entityOrId.objectId) !== null && _a !== void 0 ? _a : '');
|
|
352
|
+
if (!id)
|
|
353
|
+
return false;
|
|
354
|
+
return this._entityIds.includes(id);
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Returns the zero-based index of a member id, or `-1` when not found.
|
|
358
|
+
*
|
|
359
|
+
* Mirrors ObjectARX `AcDbGroup::getIndex`.
|
|
360
|
+
*
|
|
361
|
+
* @param id - Member object id to look up.
|
|
362
|
+
* @returns Index in the group, or `-1`.
|
|
363
|
+
*/
|
|
364
|
+
AcDbGroup.prototype.getIndex = function (id) {
|
|
365
|
+
return this._entityIds.indexOf(id);
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Creates an iterator over member object ids (in group order).
|
|
369
|
+
*
|
|
370
|
+
* Uses the shared {@link AcDbObjectIterator} pattern of this codebase
|
|
371
|
+
* (rather than ObjectARX `AcDbGroupIterator`).
|
|
372
|
+
*
|
|
373
|
+
* @returns An iterator yielding member {@link AcDbObjectId} values.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* for (const id of group.newIterator()) {
|
|
378
|
+
* const entity = db.getObjectById(id)
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
AcDbGroup.prototype.newIterator = function () {
|
|
383
|
+
return new AcDbObjectIterator(this._entityIds);
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Appends one or more member ids to the end of the group.
|
|
387
|
+
*
|
|
388
|
+
* Duplicate ids already in the group are ignored. Mirrors ObjectARX
|
|
389
|
+
* `AcDbGroup::append`.
|
|
390
|
+
*
|
|
391
|
+
* @param idOrIds - A single object id or an array of object ids.
|
|
392
|
+
*/
|
|
393
|
+
AcDbGroup.prototype.append = function (idOrIds) {
|
|
394
|
+
var e_2, _a;
|
|
395
|
+
var ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
396
|
+
try {
|
|
397
|
+
for (var ids_1 = __values(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {
|
|
398
|
+
var id = ids_1_1.value;
|
|
399
|
+
if (!id || this._entityIds.includes(id))
|
|
400
|
+
continue;
|
|
401
|
+
this._entityIds.push(id);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
405
|
+
finally {
|
|
406
|
+
try {
|
|
407
|
+
if (ids_1_1 && !ids_1_1.done && (_a = ids_1.return)) _a.call(ids_1);
|
|
408
|
+
}
|
|
409
|
+
finally { if (e_2) throw e_2.error; }
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Prepends one or more member ids to the start of the group.
|
|
414
|
+
*
|
|
415
|
+
* Duplicate ids already in the group are ignored. Mirrors ObjectARX
|
|
416
|
+
* `AcDbGroup::prepend`.
|
|
417
|
+
*
|
|
418
|
+
* @param idOrIds - A single object id or an array of object ids.
|
|
419
|
+
*/
|
|
420
|
+
AcDbGroup.prototype.prepend = function (idOrIds) {
|
|
421
|
+
var ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
422
|
+
for (var i = ids.length - 1; i >= 0; i--) {
|
|
423
|
+
var id = ids[i];
|
|
424
|
+
if (!id || this._entityIds.includes(id))
|
|
425
|
+
continue;
|
|
426
|
+
this._entityIds.unshift(id);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Inserts one or more member ids at the given index.
|
|
431
|
+
*
|
|
432
|
+
* Duplicate ids already in the group are ignored. Mirrors ObjectARX
|
|
433
|
+
* `AcDbGroup::insertAt`.
|
|
434
|
+
*
|
|
435
|
+
* @param index - Zero-based insertion index (clamped to `[0, length]`).
|
|
436
|
+
* @param idOrIds - A single object id or an array of object ids.
|
|
437
|
+
*/
|
|
438
|
+
AcDbGroup.prototype.insertAt = function (index, idOrIds) {
|
|
439
|
+
var _a;
|
|
440
|
+
var _this = this;
|
|
441
|
+
var ids = (Array.isArray(idOrIds) ? idOrIds : [idOrIds]).filter(function (id) { return !!id && !_this._entityIds.includes(id); });
|
|
442
|
+
if (ids.length === 0)
|
|
443
|
+
return;
|
|
444
|
+
var at = Math.max(0, Math.min(this._entityIds.length, Math.trunc(index)));
|
|
445
|
+
(_a = this._entityIds).splice.apply(_a, __spreadArray([at, 0], __read(ids), false));
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Removes one or more members by object id.
|
|
449
|
+
*
|
|
450
|
+
* Mirrors ObjectARX `AcDbGroup::remove`.
|
|
451
|
+
*
|
|
452
|
+
* @param idOrIds - A single object id or an array of object ids to remove.
|
|
453
|
+
*/
|
|
454
|
+
AcDbGroup.prototype.remove = function (idOrIds) {
|
|
455
|
+
var toRemove = new Set((Array.isArray(idOrIds) ? idOrIds : [idOrIds]).filter(Boolean));
|
|
456
|
+
if (toRemove.size === 0)
|
|
457
|
+
return;
|
|
458
|
+
this._entityIds = this._entityIds.filter(function (id) { return !toRemove.has(id); });
|
|
459
|
+
};
|
|
460
|
+
/**
|
|
461
|
+
* Removes a member at `index`, or removes the given ids starting from that
|
|
462
|
+
* index when `ids` is provided.
|
|
463
|
+
*
|
|
464
|
+
* Mirrors ObjectARX `AcDbGroup::removeAt`.
|
|
465
|
+
*
|
|
466
|
+
* @param index - Zero-based index of the first member to consider.
|
|
467
|
+
* @param ids - Optional subset of ids to remove from `index` onward.
|
|
468
|
+
*/
|
|
469
|
+
AcDbGroup.prototype.removeAt = function (index, ids) {
|
|
470
|
+
var at = Math.trunc(index);
|
|
471
|
+
if (at < 0 || at >= this._entityIds.length)
|
|
472
|
+
return;
|
|
473
|
+
if (ids && ids.length > 0) {
|
|
474
|
+
var toRemove_1 = new Set(ids.filter(Boolean));
|
|
475
|
+
this._entityIds = this._entityIds.filter(function (id, i) {
|
|
476
|
+
if (i < at)
|
|
477
|
+
return true;
|
|
478
|
+
return !toRemove_1.has(id);
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
this._entityIds.splice(at, 1);
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* Replaces one member id with another.
|
|
486
|
+
*
|
|
487
|
+
* If `newId` is already in the group, `oldId` is simply removed. Mirrors
|
|
488
|
+
* ObjectARX `AcDbGroup::replace`.
|
|
489
|
+
*
|
|
490
|
+
* @param oldId - Existing member object id.
|
|
491
|
+
* @param newId - Replacement object id.
|
|
492
|
+
*/
|
|
493
|
+
AcDbGroup.prototype.replace = function (oldId, newId) {
|
|
494
|
+
if (!oldId || !newId || oldId === newId)
|
|
495
|
+
return;
|
|
496
|
+
var index = this._entityIds.indexOf(oldId);
|
|
497
|
+
if (index < 0)
|
|
498
|
+
return;
|
|
499
|
+
if (this._entityIds.includes(newId)) {
|
|
500
|
+
this._entityIds.splice(index, 1);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
this._entityIds[index] = newId;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Moves `num` members starting at `fromIndex` so they begin at `toIndex`.
|
|
507
|
+
*
|
|
508
|
+
* Mirrors ObjectARX `AcDbGroup::transfer`.
|
|
509
|
+
*
|
|
510
|
+
* @param fromIndex - Start index of the block to move.
|
|
511
|
+
* @param toIndex - Destination index for the block.
|
|
512
|
+
* @param num - Number of members to move.
|
|
513
|
+
*/
|
|
514
|
+
AcDbGroup.prototype.transfer = function (fromIndex, toIndex, num) {
|
|
515
|
+
var _a;
|
|
516
|
+
var from = Math.trunc(fromIndex);
|
|
517
|
+
var to = Math.trunc(toIndex);
|
|
518
|
+
var count = Math.trunc(num);
|
|
519
|
+
if (count <= 0 || from < 0 || from >= this._entityIds.length)
|
|
520
|
+
return;
|
|
521
|
+
var slice = this._entityIds.splice(from, count);
|
|
522
|
+
var insertAt = to;
|
|
523
|
+
if (to > from)
|
|
524
|
+
insertAt = Math.max(0, to - slice.length);
|
|
525
|
+
insertAt = Math.max(0, Math.min(this._entityIds.length, insertAt));
|
|
526
|
+
(_a = this._entityIds).splice.apply(_a, __spreadArray([insertAt, 0], __read(slice), false));
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* Reverses the order of members in the group.
|
|
530
|
+
*
|
|
531
|
+
* Mirrors ObjectARX `AcDbGroup::reverse`.
|
|
532
|
+
*/
|
|
533
|
+
AcDbGroup.prototype.reverse = function () {
|
|
534
|
+
this._entityIds.reverse();
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Removes all members from the group.
|
|
538
|
+
*
|
|
539
|
+
* Mirrors ObjectARX `AcDbGroup::clear`.
|
|
540
|
+
*/
|
|
541
|
+
AcDbGroup.prototype.clear = function () {
|
|
542
|
+
this._entityIds = [];
|
|
543
|
+
};
|
|
544
|
+
/**
|
|
545
|
+
* Sets the color of every resolvable member entity.
|
|
546
|
+
*
|
|
547
|
+
* Mirrors ObjectARX `AcDbGroup::setColor`.
|
|
548
|
+
*
|
|
549
|
+
* @param color - Color to apply (cloned onto each entity).
|
|
550
|
+
*/
|
|
551
|
+
AcDbGroup.prototype.setColor = function (color) {
|
|
552
|
+
var e_3, _a;
|
|
553
|
+
try {
|
|
554
|
+
for (var _b = __values(this.memberEntities()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
555
|
+
var entity = _c.value;
|
|
556
|
+
entity.color = color.clone();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
560
|
+
finally {
|
|
561
|
+
try {
|
|
562
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
563
|
+
}
|
|
564
|
+
finally { if (e_3) throw e_3.error; }
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Sets the ACI color of every resolvable member entity.
|
|
569
|
+
*
|
|
570
|
+
* Mirrors ObjectARX `AcDbGroup::setColorIndex`.
|
|
571
|
+
*
|
|
572
|
+
* @param index - AutoCAD Color Index (`0`–`256`).
|
|
573
|
+
*/
|
|
574
|
+
AcDbGroup.prototype.setColorIndex = function (index) {
|
|
575
|
+
var color = new AcCmColor();
|
|
576
|
+
color.colorIndex = index;
|
|
577
|
+
this.setColor(color);
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* Sets the layer of every resolvable member entity.
|
|
581
|
+
*
|
|
582
|
+
* Mirrors ObjectARX `AcDbGroup::setLayer`. When `layerOrId` is an object id
|
|
583
|
+
* of a layer table record, the record's name is used.
|
|
584
|
+
*
|
|
585
|
+
* @param layerOrId - Layer name or layer-table-record object id.
|
|
586
|
+
*/
|
|
587
|
+
AcDbGroup.prototype.setLayer = function (layerOrId) {
|
|
588
|
+
var e_4, _a;
|
|
589
|
+
var layerName = this.resolveLayerName(layerOrId);
|
|
590
|
+
if (!layerName)
|
|
591
|
+
return;
|
|
592
|
+
try {
|
|
593
|
+
for (var _b = __values(this.memberEntities()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
594
|
+
var entity = _c.value;
|
|
595
|
+
entity.layer = layerName;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
599
|
+
finally {
|
|
600
|
+
try {
|
|
601
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
602
|
+
}
|
|
603
|
+
finally { if (e_4) throw e_4.error; }
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Sets the linetype of every resolvable member entity.
|
|
608
|
+
*
|
|
609
|
+
* Mirrors ObjectARX `AcDbGroup::setLinetype`. When `linetypeOrId` is an
|
|
610
|
+
* object id of a linetype table record, the record's name is used.
|
|
611
|
+
*
|
|
612
|
+
* @param linetypeOrId - Linetype name or linetype-table-record object id.
|
|
613
|
+
*/
|
|
614
|
+
AcDbGroup.prototype.setLinetype = function (linetypeOrId) {
|
|
615
|
+
var e_5, _a;
|
|
616
|
+
var name = this.resolveLinetypeName(linetypeOrId);
|
|
617
|
+
if (!name)
|
|
618
|
+
return;
|
|
619
|
+
try {
|
|
620
|
+
for (var _b = __values(this.memberEntities()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
621
|
+
var entity = _c.value;
|
|
622
|
+
entity.lineType = name;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
626
|
+
finally {
|
|
627
|
+
try {
|
|
628
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
629
|
+
}
|
|
630
|
+
finally { if (e_5) throw e_5.error; }
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Sets the linetype scale of every resolvable member entity.
|
|
635
|
+
*
|
|
636
|
+
* Mirrors ObjectARX `AcDbGroup::setLinetypeScale`.
|
|
637
|
+
*
|
|
638
|
+
* @param scale - Linetype scale factor.
|
|
639
|
+
*/
|
|
640
|
+
AcDbGroup.prototype.setLinetypeScale = function (scale) {
|
|
641
|
+
var e_6, _a;
|
|
642
|
+
try {
|
|
643
|
+
for (var _b = __values(this.memberEntities()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
644
|
+
var entity = _c.value;
|
|
645
|
+
entity.linetypeScale = scale;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
649
|
+
finally {
|
|
650
|
+
try {
|
|
651
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
652
|
+
}
|
|
653
|
+
finally { if (e_6) throw e_6.error; }
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* Sets the material of every resolvable member entity.
|
|
658
|
+
*
|
|
659
|
+
* Mirrors ObjectARX `AcDbGroup::setMaterial`. Currently a no-op because
|
|
660
|
+
* entities keep material as a raw DXF extra without a typed setter.
|
|
661
|
+
*
|
|
662
|
+
* @param _materialOrId - Material name or material object id.
|
|
663
|
+
*/
|
|
664
|
+
AcDbGroup.prototype.setMaterial = function (_materialOrId) {
|
|
665
|
+
// Entities keep material as a raw DXF extra today; no typed setter yet.
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* Sets the visibility of every resolvable member entity.
|
|
669
|
+
*
|
|
670
|
+
* Mirrors ObjectARX `AcDbGroup::setVisibility`.
|
|
671
|
+
*
|
|
672
|
+
* @param visible - `true` to show members; `false` to hide them.
|
|
673
|
+
*/
|
|
674
|
+
AcDbGroup.prototype.setVisibility = function (visible) {
|
|
675
|
+
var e_7, _a;
|
|
676
|
+
try {
|
|
677
|
+
for (var _b = __values(this.memberEntities()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
678
|
+
var entity = _c.value;
|
|
679
|
+
entity.visibility = visible;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
683
|
+
finally {
|
|
684
|
+
try {
|
|
685
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
686
|
+
}
|
|
687
|
+
finally { if (e_7) throw e_7.error; }
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
/**
|
|
691
|
+
* Sets the highlight state of every resolvable member entity.
|
|
692
|
+
*
|
|
693
|
+
* Mirrors ObjectARX `AcDbGroup::setHighlight`. Currently a no-op because
|
|
694
|
+
* this model has no per-entity highlight persistence.
|
|
695
|
+
*
|
|
696
|
+
* @param _highlight - Desired highlight state.
|
|
697
|
+
*/
|
|
698
|
+
AcDbGroup.prototype.setHighlight = function (_highlight) {
|
|
699
|
+
// No per-entity highlight persistence in this model.
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* Writes DXF subclass fields for this group.
|
|
703
|
+
*
|
|
704
|
+
* @param filer - DXF output writer.
|
|
705
|
+
* @returns This instance for chaining.
|
|
706
|
+
*/
|
|
707
|
+
AcDbGroup.prototype.dxfOutFields = function (filer) {
|
|
708
|
+
var e_8, _a;
|
|
114
709
|
_super.prototype.dxfOutFields.call(this, filer);
|
|
115
710
|
filer.writeSubclassMarker('AcDbGroup');
|
|
116
|
-
if (this.
|
|
117
|
-
filer.writeString(300, this.
|
|
711
|
+
if (this._description) {
|
|
712
|
+
filer.writeString(300, this._description);
|
|
118
713
|
}
|
|
119
|
-
filer.writeInt16(70, this.
|
|
120
|
-
filer.writeInt16(71, this.
|
|
714
|
+
filer.writeInt16(70, this._anonymous ? 1 : 0);
|
|
715
|
+
filer.writeInt16(71, this._selectable ? 1 : 0);
|
|
121
716
|
try {
|
|
122
717
|
for (var _b = __values(this._entityIds), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
123
718
|
var id = _c.value;
|
|
124
719
|
filer.writeObjectId(340, id);
|
|
125
720
|
}
|
|
126
721
|
}
|
|
127
|
-
catch (
|
|
722
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
128
723
|
finally {
|
|
129
724
|
try {
|
|
130
725
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
131
726
|
}
|
|
132
|
-
finally { if (
|
|
727
|
+
finally { if (e_8) throw e_8.error; }
|
|
133
728
|
}
|
|
134
729
|
return this;
|
|
135
730
|
};
|
|
731
|
+
/**
|
|
732
|
+
* Reads DXF subclass fields for this group.
|
|
733
|
+
*
|
|
734
|
+
* @param filer - DXF input reader positioned at this object.
|
|
735
|
+
* @returns This instance for chaining.
|
|
736
|
+
*/
|
|
136
737
|
AcDbGroup.prototype.dxfInFields = function (filer) {
|
|
137
738
|
_super.prototype.dxfInFields.call(this, filer);
|
|
138
739
|
filer.atSubclassData('AcDbGroup');
|
|
@@ -148,13 +749,13 @@ var AcDbGroup = /** @class */ (function (_super) {
|
|
|
148
749
|
}
|
|
149
750
|
switch (code) {
|
|
150
751
|
case 300:
|
|
151
|
-
this.
|
|
752
|
+
this.description = item.value;
|
|
152
753
|
break;
|
|
153
754
|
case 70:
|
|
154
|
-
this.
|
|
755
|
+
this.anonymous = Number(item.value) !== 0;
|
|
155
756
|
break;
|
|
156
757
|
case 71:
|
|
157
|
-
this.
|
|
758
|
+
this.selectable = Number(item.value) !== 0;
|
|
158
759
|
break;
|
|
159
760
|
case 340:
|
|
160
761
|
this._entityIds.push(String(item.value));
|
|
@@ -165,6 +766,72 @@ var AcDbGroup = /** @class */ (function (_super) {
|
|
|
165
766
|
}
|
|
166
767
|
return this;
|
|
167
768
|
};
|
|
769
|
+
/**
|
|
770
|
+
* Resolves member ids to {@link AcDbEntity} instances via the owning
|
|
771
|
+
* database. Non-entity or missing ids are skipped.
|
|
772
|
+
*
|
|
773
|
+
* @returns Entities currently resolvable from {@link entityIds}.
|
|
774
|
+
*/
|
|
775
|
+
AcDbGroup.prototype.memberEntities = function () {
|
|
776
|
+
var e_9, _a;
|
|
777
|
+
var db = this.database;
|
|
778
|
+
if (!db)
|
|
779
|
+
return [];
|
|
780
|
+
var result = [];
|
|
781
|
+
try {
|
|
782
|
+
for (var _b = __values(this._entityIds), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
783
|
+
var id = _c.value;
|
|
784
|
+
var obj = db.getObjectById(id);
|
|
785
|
+
if (obj instanceof AcDbEntity)
|
|
786
|
+
result.push(obj);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
790
|
+
finally {
|
|
791
|
+
try {
|
|
792
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
793
|
+
}
|
|
794
|
+
finally { if (e_9) throw e_9.error; }
|
|
795
|
+
}
|
|
796
|
+
return result;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Resolves a layer name from a name string or layer-table-record object id.
|
|
800
|
+
*
|
|
801
|
+
* @param layerOrId - Layer name or object id.
|
|
802
|
+
* @returns Layer name to apply to member entities.
|
|
803
|
+
*/
|
|
804
|
+
AcDbGroup.prototype.resolveLayerName = function (layerOrId) {
|
|
805
|
+
var db = this.database;
|
|
806
|
+
if (!db)
|
|
807
|
+
return String(layerOrId !== null && layerOrId !== void 0 ? layerOrId : '');
|
|
808
|
+
var asId = db.getObjectById(layerOrId);
|
|
809
|
+
if (asId &&
|
|
810
|
+
'name' in asId &&
|
|
811
|
+
typeof asId.name === 'string') {
|
|
812
|
+
return asId.name;
|
|
813
|
+
}
|
|
814
|
+
return String(layerOrId !== null && layerOrId !== void 0 ? layerOrId : '');
|
|
815
|
+
};
|
|
816
|
+
/**
|
|
817
|
+
* Resolves a linetype name from a name string or linetype-table-record
|
|
818
|
+
* object id.
|
|
819
|
+
*
|
|
820
|
+
* @param linetypeOrId - Linetype name or object id.
|
|
821
|
+
* @returns Linetype name to apply to member entities.
|
|
822
|
+
*/
|
|
823
|
+
AcDbGroup.prototype.resolveLinetypeName = function (linetypeOrId) {
|
|
824
|
+
var db = this.database;
|
|
825
|
+
if (!db)
|
|
826
|
+
return String(linetypeOrId !== null && linetypeOrId !== void 0 ? linetypeOrId : '');
|
|
827
|
+
var asId = db.getObjectById(linetypeOrId);
|
|
828
|
+
if (asId &&
|
|
829
|
+
'name' in asId &&
|
|
830
|
+
typeof asId.name === 'string') {
|
|
831
|
+
return asId.name;
|
|
832
|
+
}
|
|
833
|
+
return String(linetypeOrId !== null && linetypeOrId !== void 0 ? linetypeOrId : '');
|
|
834
|
+
};
|
|
168
835
|
return AcDbGroup;
|
|
169
836
|
}(AcDbObject));
|
|
170
837
|
export { AcDbGroup };
|