altium-to-circuit-json 0.0.97 → 0.0.98
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/index.js +47 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3391,6 +3391,9 @@ function convertComponentPin({
|
|
|
3391
3391
|
};
|
|
3392
3392
|
}
|
|
3393
3393
|
|
|
3394
|
+
// lib/schematic/components/convertMarkedCapacitorBody.ts
|
|
3395
|
+
import { AltiumSchLabelRecord } from "altiumts";
|
|
3396
|
+
|
|
3394
3397
|
// lib/schematic/components/convertOwnedCustomComponentBody.ts
|
|
3395
3398
|
import {
|
|
3396
3399
|
AltiumSchArcRecord,
|
|
@@ -3540,6 +3543,20 @@ function convertOwnedCustomComponentBody({
|
|
|
3540
3543
|
return prepareOwnedComponentBodyElements(ownedElements);
|
|
3541
3544
|
}
|
|
3542
3545
|
|
|
3546
|
+
// lib/schematic/components/convertMarkedCapacitorBody.ts
|
|
3547
|
+
function convertMarkedCapacitorBody({
|
|
3548
|
+
identity,
|
|
3549
|
+
records,
|
|
3550
|
+
symbolSelection
|
|
3551
|
+
}, context) {
|
|
3552
|
+
if (!symbolSelection?.name.startsWith("capacitor_") || symbolSelection.name.startsWith("capacitor_polarized_") || !records.some(
|
|
3553
|
+
(record) => record instanceof AltiumSchLabelRecord && !record.getBoolean("ISHIDDEN") && record.text?.trim() === "+"
|
|
3554
|
+
)) {
|
|
3555
|
+
return void 0;
|
|
3556
|
+
}
|
|
3557
|
+
return convertOwnedCustomComponentBody({ identity, records }, context);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3543
3560
|
// lib/schematic/components/normalizeLogicGatePinName.ts
|
|
3544
3561
|
function normalizeLogicGatePinName(name) {
|
|
3545
3562
|
return name?.trim().toUpperCase().replace(/^\d+(?=[A-Z]+$)/u, "");
|
|
@@ -4155,12 +4172,28 @@ function getComponentIdentity({
|
|
|
4155
4172
|
};
|
|
4156
4173
|
}
|
|
4157
4174
|
|
|
4175
|
+
// lib/schematic/components/getComponentSize.ts
|
|
4176
|
+
function getComponentSize({
|
|
4177
|
+
bodyBounds,
|
|
4178
|
+
scale: scale5,
|
|
4179
|
+
symbolSelection
|
|
4180
|
+
}) {
|
|
4181
|
+
if (symbolSelection) return { ...symbolSelection.symbol.size };
|
|
4182
|
+
return {
|
|
4183
|
+
height: Math.max(
|
|
4184
|
+
scaleLength(bodyBounds.maxY - bodyBounds.minY, scale5),
|
|
4185
|
+
0.4
|
|
4186
|
+
),
|
|
4187
|
+
width: Math.max(scaleLength(bodyBounds.maxX - bodyBounds.minX, scale5), 0.4)
|
|
4188
|
+
};
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4158
4191
|
// lib/schematic/components/getVisibleSymbolLabels.ts
|
|
4159
|
-
import { AltiumSchLabelRecord } from "altiumts";
|
|
4192
|
+
import { AltiumSchLabelRecord as AltiumSchLabelRecord2 } from "altiumts";
|
|
4160
4193
|
function getVisibleSymbolLabels(records) {
|
|
4161
4194
|
return new Set(
|
|
4162
4195
|
records.filter(
|
|
4163
|
-
(record) => record instanceof
|
|
4196
|
+
(record) => record instanceof AltiumSchLabelRecord2
|
|
4164
4197
|
).flatMap((record) => {
|
|
4165
4198
|
const text = record.text?.trim().toUpperCase();
|
|
4166
4199
|
return text ? [text] : [];
|
|
@@ -4233,29 +4266,29 @@ function convertComponent({
|
|
|
4233
4266
|
visibleOwnedRecords,
|
|
4234
4267
|
componentPorts.map(({ point }) => point)
|
|
4235
4268
|
);
|
|
4236
|
-
|
|
4269
|
+
let symbolSelection = selectCircuitJsonSymbol({
|
|
4237
4270
|
...identity,
|
|
4238
4271
|
ports: componentPorts
|
|
4239
4272
|
});
|
|
4273
|
+
const polarizedCapacitorBody = convertMarkedCapacitorBody(
|
|
4274
|
+
{ identity, records: visibleOwnedRecords, symbolSelection },
|
|
4275
|
+
context
|
|
4276
|
+
);
|
|
4277
|
+
if (polarizedCapacitorBody) symbolSelection = void 0;
|
|
4240
4278
|
const singleInputGateBody = symbolSelection ? void 0 : convertOwnedSingleInputGateBody(
|
|
4241
4279
|
{ identity, records: visibleOwnedRecords, componentPorts },
|
|
4242
4280
|
context
|
|
4243
4281
|
);
|
|
4244
|
-
const ownedComponentBody = singleInputGateBody ?? (symbolSelection ? void 0 : convertOwnedComponentBody(
|
|
4282
|
+
const ownedComponentBody = polarizedCapacitorBody ?? singleInputGateBody ?? (symbolSelection ? void 0 : convertOwnedComponentBody(
|
|
4245
4283
|
{ identity, pins, records: visibleOwnedRecords, visibleSymbolLabels },
|
|
4246
4284
|
context
|
|
4247
4285
|
));
|
|
4248
4286
|
const center = scalePoint(getBoundsCenter(bodyBounds), options.scale);
|
|
4249
|
-
const size =
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
width: Math.max(
|
|
4255
|
-
scaleLength(bodyBounds.maxX - bodyBounds.minX, options.scale),
|
|
4256
|
-
0.4
|
|
4257
|
-
)
|
|
4258
|
-
};
|
|
4287
|
+
const size = getComponentSize({
|
|
4288
|
+
bodyBounds,
|
|
4289
|
+
scale: options.scale,
|
|
4290
|
+
symbolSelection
|
|
4291
|
+
});
|
|
4259
4292
|
if (symbolSelection) {
|
|
4260
4293
|
applyNativeSymbolPortGeometry({ center, selection: symbolSelection });
|
|
4261
4294
|
}
|