altium-to-circuit-json 0.0.68 → 0.0.69
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 +161 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1641,10 +1641,7 @@ function addComponentFallbackText({
|
|
|
1641
1641
|
}
|
|
1642
1642
|
|
|
1643
1643
|
// lib/schematic/components/convertComponent.ts
|
|
1644
|
-
import {
|
|
1645
|
-
AltiumSchLabelRecord,
|
|
1646
|
-
AltiumSchPinRecord as AltiumSchPinRecord3
|
|
1647
|
-
} from "altiumts";
|
|
1644
|
+
import { AltiumSchPinRecord as AltiumSchPinRecord3 } from "altiumts";
|
|
1648
1645
|
|
|
1649
1646
|
// lib/schematic/symbols/applyNativeSymbolPortGeometry.ts
|
|
1650
1647
|
import { applyToPoint as applyToPoint6, translate as translate2 } from "transformation-matrix";
|
|
@@ -2842,6 +2839,47 @@ function convertComponentPin({
|
|
|
2842
2839
|
};
|
|
2843
2840
|
}
|
|
2844
2841
|
|
|
2842
|
+
// lib/schematic/rendering/convertSchematicArcToPath.ts
|
|
2843
|
+
import {
|
|
2844
|
+
applyToPoint as applyToPoint7,
|
|
2845
|
+
compose as compose2,
|
|
2846
|
+
rotateDEG as rotateDEG2,
|
|
2847
|
+
translate as translate3
|
|
2848
|
+
} from "transformation-matrix";
|
|
2849
|
+
var MAXIMUM_ARC_STEP_DEGREES = 7.5;
|
|
2850
|
+
function convertSchematicArcToPath(schematicArc) {
|
|
2851
|
+
const rawSpanDegrees = schematicArc.end_angle_degrees - schematicArc.start_angle_degrees;
|
|
2852
|
+
const normalizedCounterclockwiseSpan = (rawSpanDegrees % 360 + 360) % 360;
|
|
2853
|
+
const counterclockwiseSpanDegrees = normalizedCounterclockwiseSpan === 0 && rawSpanDegrees !== 0 ? 360 : normalizedCounterclockwiseSpan;
|
|
2854
|
+
const signedSpanDegrees = schematicArc.direction === "clockwise" ? counterclockwiseSpanDegrees - 360 : counterclockwiseSpanDegrees;
|
|
2855
|
+
const segmentCount = Math.max(
|
|
2856
|
+
Math.ceil(Math.abs(signedSpanDegrees) / MAXIMUM_ARC_STEP_DEGREES),
|
|
2857
|
+
1
|
|
2858
|
+
);
|
|
2859
|
+
const points = Array.from({ length: segmentCount + 1 }, (_, index) => {
|
|
2860
|
+
const ccwRotationDegrees = schematicArc.start_angle_degrees + signedSpanDegrees * index / segmentCount;
|
|
2861
|
+
const arcToSchematic = compose2(
|
|
2862
|
+
translate3(schematicArc.center.x, schematicArc.center.y),
|
|
2863
|
+
rotateDEG2(ccwRotationDegrees)
|
|
2864
|
+
);
|
|
2865
|
+
return applyToPoint7(arcToSchematic, { x: schematicArc.radius, y: 0 });
|
|
2866
|
+
});
|
|
2867
|
+
return {
|
|
2868
|
+
type: "schematic_path",
|
|
2869
|
+
schematic_path_id: schematicArc.schematic_arc_id.replace(
|
|
2870
|
+
"schematic_arc_",
|
|
2871
|
+
"schematic_path_"
|
|
2872
|
+
),
|
|
2873
|
+
schematic_sheet_id: schematicArc.schematic_sheet_id,
|
|
2874
|
+
schematic_component_id: schematicArc.schematic_component_id,
|
|
2875
|
+
is_dashed: schematicArc.is_dashed,
|
|
2876
|
+
is_filled: false,
|
|
2877
|
+
points,
|
|
2878
|
+
stroke_color: schematicArc.color,
|
|
2879
|
+
stroke_width: schematicArc.stroke_width
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2845
2883
|
// lib/schematic/components/convertOwnedComponentRecords.ts
|
|
2846
2884
|
import {
|
|
2847
2885
|
AltiumSchImageRecord as AltiumSchImageRecord2,
|
|
@@ -2882,6 +2920,42 @@ function convertOwnedComponentRecords({
|
|
|
2882
2920
|
});
|
|
2883
2921
|
}
|
|
2884
2922
|
|
|
2923
|
+
// lib/schematic/components/convertOwnedLogicGateBody.ts
|
|
2924
|
+
function convertOwnedLogicGateBody({
|
|
2925
|
+
identity,
|
|
2926
|
+
pins,
|
|
2927
|
+
records,
|
|
2928
|
+
visibleSymbolLabels
|
|
2929
|
+
}, context) {
|
|
2930
|
+
const logicGateLabels = /* @__PURE__ */ new Set([
|
|
2931
|
+
...visibleSymbolLabels,
|
|
2932
|
+
...pins.flatMap((pin) => {
|
|
2933
|
+
const name = pin.getDecoded("NAME")?.trim().toUpperCase();
|
|
2934
|
+
return name ? [name] : [];
|
|
2935
|
+
})
|
|
2936
|
+
]);
|
|
2937
|
+
if (!["A", "B", "Y"].every((label) => logicGateLabels.has(label))) {
|
|
2938
|
+
return void 0;
|
|
2939
|
+
}
|
|
2940
|
+
const ownedElements = convertOwnedComponentRecords(
|
|
2941
|
+
{
|
|
2942
|
+
ownedRecords: records,
|
|
2943
|
+
schematicComponentId: identity.schematicComponentId
|
|
2944
|
+
},
|
|
2945
|
+
context
|
|
2946
|
+
);
|
|
2947
|
+
if (!ownedElements.some((element) => element.type === "schematic_arc")) {
|
|
2948
|
+
return void 0;
|
|
2949
|
+
}
|
|
2950
|
+
return ownedElements.map(
|
|
2951
|
+
(element) => element.type === "schematic_arc" ? convertSchematicArcToPath(element) : element
|
|
2952
|
+
).sort((left, right) => {
|
|
2953
|
+
const leftIsFilled = "is_filled" in left && left.is_filled === true ? 1 : 0;
|
|
2954
|
+
const rightIsFilled = "is_filled" in right && right.is_filled === true ? 1 : 0;
|
|
2955
|
+
return rightIsFilled - leftIsFilled;
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2885
2959
|
// lib/schematic/components/getComponentBodyBounds.ts
|
|
2886
2960
|
import {
|
|
2887
2961
|
AltiumSchEllipseRecord,
|
|
@@ -3010,13 +3084,52 @@ function createAlphanumericPinDesignatorText({
|
|
|
3010
3084
|
};
|
|
3011
3085
|
}
|
|
3012
3086
|
|
|
3013
|
-
// lib/schematic/components/
|
|
3087
|
+
// lib/schematic/components/createNumericPinDesignatorText.ts
|
|
3014
3088
|
var EDGE_VECTOR_BY_SIDE2 = {
|
|
3015
3089
|
bottom: { x: 0, y: 1 },
|
|
3016
3090
|
left: { x: 1, y: 0 },
|
|
3017
3091
|
right: { x: -1, y: 0 },
|
|
3018
3092
|
top: { x: 0, y: -1 }
|
|
3019
3093
|
};
|
|
3094
|
+
function createNumericPinDesignatorText({
|
|
3095
|
+
pin,
|
|
3096
|
+
recordIndex,
|
|
3097
|
+
scale: scale5,
|
|
3098
|
+
schematicPort
|
|
3099
|
+
}) {
|
|
3100
|
+
const designator = pin.designator;
|
|
3101
|
+
if (!designator || parsePinNumber(designator) === void 0) return void 0;
|
|
3102
|
+
const pinConglomerate = pin.pinConglomerate;
|
|
3103
|
+
const isDesignatorVisible = pinConglomerate === void 0 || (pinConglomerate & 16) !== 0;
|
|
3104
|
+
const side = schematicPort.side_of_component;
|
|
3105
|
+
if (!isDesignatorVisible || !side) return void 0;
|
|
3106
|
+
const edgeVector = EDGE_VECTOR_BY_SIDE2[side];
|
|
3107
|
+
const halfPinLength = (schematicPort.distance_from_component_edge ?? 0.4) / 2;
|
|
3108
|
+
const position = {
|
|
3109
|
+
x: schematicPort.center.x + edgeVector.x * halfPinLength,
|
|
3110
|
+
y: schematicPort.center.y + edgeVector.y * halfPinLength
|
|
3111
|
+
};
|
|
3112
|
+
return {
|
|
3113
|
+
type: "schematic_text",
|
|
3114
|
+
anchor: "bottom_center",
|
|
3115
|
+
color: "#a90000",
|
|
3116
|
+
font_size: Math.max(scaleLength(1.5, scale5), 0.15),
|
|
3117
|
+
position,
|
|
3118
|
+
rotation: side === "top" || side === "bottom" ? -90 : 0,
|
|
3119
|
+
// Primitive component bodies render their text as sheet-level elements.
|
|
3120
|
+
schematic_sheet_id: schematicPort.schematic_sheet_id,
|
|
3121
|
+
schematic_text_id: `schematic_pin_designator_altium_${recordIndex}`,
|
|
3122
|
+
text: designator
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
// lib/schematic/components/createPinClockSymbol.ts
|
|
3127
|
+
var EDGE_VECTOR_BY_SIDE3 = {
|
|
3128
|
+
bottom: { x: 0, y: 1 },
|
|
3129
|
+
left: { x: 1, y: 0 },
|
|
3130
|
+
right: { x: -1, y: 0 },
|
|
3131
|
+
top: { x: 0, y: -1 }
|
|
3132
|
+
};
|
|
3020
3133
|
function createPinClockSymbol({
|
|
3021
3134
|
pin,
|
|
3022
3135
|
recordIndex,
|
|
@@ -3025,7 +3138,7 @@ function createPinClockSymbol({
|
|
|
3025
3138
|
}) {
|
|
3026
3139
|
const side = schematicPort.side_of_component;
|
|
3027
3140
|
if (pin.getNumber("SYMBOL_INNEREDGE") !== 3 || !side) return void 0;
|
|
3028
|
-
const edgeVector =
|
|
3141
|
+
const edgeVector = EDGE_VECTOR_BY_SIDE3[side];
|
|
3029
3142
|
const pinLength = schematicPort.distance_from_component_edge ?? 0.4;
|
|
3030
3143
|
const bodyPosition = {
|
|
3031
3144
|
x: schematicPort.center.x + edgeVector.x * pinLength,
|
|
@@ -3063,6 +3176,7 @@ function createPinClockSymbol({
|
|
|
3063
3176
|
// lib/schematic/components/createComponentPinEdgeElements.ts
|
|
3064
3177
|
function createComponentPinEdgeElements({
|
|
3065
3178
|
componentPorts,
|
|
3179
|
+
includeNumericDesignators,
|
|
3066
3180
|
pins
|
|
3067
3181
|
}, context) {
|
|
3068
3182
|
return componentPorts.flatMap(
|
|
@@ -3078,6 +3192,7 @@ function createComponentPinEdgeElements({
|
|
|
3078
3192
|
};
|
|
3079
3193
|
return [
|
|
3080
3194
|
createAlphanumericPinDesignatorText(edgeElementParameters),
|
|
3195
|
+
includeNumericDesignators ? createNumericPinDesignatorText(edgeElementParameters) : void 0,
|
|
3081
3196
|
createPinClockSymbol(edgeElementParameters)
|
|
3082
3197
|
].filter((element) => element !== void 0);
|
|
3083
3198
|
}
|
|
@@ -3252,6 +3367,19 @@ function getComponentIdentity({
|
|
|
3252
3367
|
};
|
|
3253
3368
|
}
|
|
3254
3369
|
|
|
3370
|
+
// lib/schematic/components/getVisibleSymbolLabels.ts
|
|
3371
|
+
import { AltiumSchLabelRecord } from "altiumts";
|
|
3372
|
+
function getVisibleSymbolLabels(records) {
|
|
3373
|
+
return new Set(
|
|
3374
|
+
records.filter(
|
|
3375
|
+
(record) => record instanceof AltiumSchLabelRecord
|
|
3376
|
+
).flatMap((record) => {
|
|
3377
|
+
const text = record.text?.trim().toUpperCase();
|
|
3378
|
+
return text ? [text] : [];
|
|
3379
|
+
})
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3255
3383
|
// lib/schematic/components/isOwnedRecordVisible.ts
|
|
3256
3384
|
function isOwnedRecordVisible(record, currentPartId) {
|
|
3257
3385
|
const ownerPartId = record.getNumber("OWNERPARTID");
|
|
@@ -3304,14 +3432,7 @@ function convertComponent({
|
|
|
3304
3432
|
);
|
|
3305
3433
|
return;
|
|
3306
3434
|
}
|
|
3307
|
-
const visibleSymbolLabels =
|
|
3308
|
-
visibleOwnedRecords.filter(
|
|
3309
|
-
(record) => record instanceof AltiumSchLabelRecord
|
|
3310
|
-
).flatMap((record) => {
|
|
3311
|
-
const text = record.text?.trim().toUpperCase();
|
|
3312
|
-
return text ? [text] : [];
|
|
3313
|
-
})
|
|
3314
|
-
);
|
|
3435
|
+
const visibleSymbolLabels = getVisibleSymbolLabels(visibleOwnedRecords);
|
|
3315
3436
|
const componentPorts = pins.map(
|
|
3316
3437
|
(pin, pinIndex) => convertComponentPin({
|
|
3317
3438
|
document,
|
|
@@ -3332,6 +3453,11 @@ function convertComponent({
|
|
|
3332
3453
|
libraryReference: identity.libraryReference,
|
|
3333
3454
|
ports: componentPorts
|
|
3334
3455
|
});
|
|
3456
|
+
const ownedLogicGateBody = symbolSelection ? void 0 : convertOwnedLogicGateBody(
|
|
3457
|
+
{ identity, pins, records: visibleOwnedRecords, visibleSymbolLabels },
|
|
3458
|
+
context
|
|
3459
|
+
);
|
|
3460
|
+
const hasOwnedLogicGateBody = ownedLogicGateBody !== void 0;
|
|
3335
3461
|
const center = scalePoint(getBoundsCenter(bodyBounds), options.scale);
|
|
3336
3462
|
const size = symbolSelection ? { ...symbolSelection.symbol.size } : {
|
|
3337
3463
|
height: Math.max(
|
|
@@ -3347,7 +3473,11 @@ function convertComponent({
|
|
|
3347
3473
|
applyNativeSymbolPortGeometry({ center, selection: symbolSelection });
|
|
3348
3474
|
}
|
|
3349
3475
|
const pinEdgeElements = createComponentPinEdgeElements(
|
|
3350
|
-
{
|
|
3476
|
+
{
|
|
3477
|
+
componentPorts,
|
|
3478
|
+
includeNumericDesignators: hasOwnedLogicGateBody,
|
|
3479
|
+
pins
|
|
3480
|
+
},
|
|
3351
3481
|
context
|
|
3352
3482
|
);
|
|
3353
3483
|
convertedPorts.push(...componentPorts);
|
|
@@ -3358,12 +3488,13 @@ function convertComponent({
|
|
|
3358
3488
|
...isSchematicVisible ? [schematicPort] : []
|
|
3359
3489
|
]
|
|
3360
3490
|
),
|
|
3361
|
-
...pinEdgeElements
|
|
3491
|
+
...pinEdgeElements,
|
|
3492
|
+
...ownedLogicGateBody ?? []
|
|
3362
3493
|
);
|
|
3363
3494
|
const schematicComponent = {
|
|
3364
3495
|
type: "schematic_component",
|
|
3365
3496
|
center,
|
|
3366
|
-
is_box_with_pins:
|
|
3497
|
+
is_box_with_pins: !hasOwnedLogicGateBody,
|
|
3367
3498
|
schematic_component_id: identity.schematicComponentId,
|
|
3368
3499
|
schematic_sheet_id: options.schematicSheetId,
|
|
3369
3500
|
size,
|
|
@@ -3372,7 +3503,7 @@ function convertComponent({
|
|
|
3372
3503
|
...symbolSelection ? { symbol_name: symbolSelection.name } : {}
|
|
3373
3504
|
};
|
|
3374
3505
|
elements.push(schematicComponent);
|
|
3375
|
-
if (!symbolSelection && options.includeText !== false) {
|
|
3506
|
+
if (!symbolSelection && !hasOwnedLogicGateBody && options.includeText !== false) {
|
|
3376
3507
|
addComponentFallbackText({
|
|
3377
3508
|
componentIndex,
|
|
3378
3509
|
designator: identity.designator,
|
|
@@ -3700,10 +3831,10 @@ function createSchematicConversionContext({
|
|
|
3700
3831
|
}
|
|
3701
3832
|
|
|
3702
3833
|
// lib/schematic/document/translateSchematicPoint.ts
|
|
3703
|
-
import { applyToPoint as
|
|
3834
|
+
import { applyToPoint as applyToPoint8, translate as translate4 } from "transformation-matrix";
|
|
3704
3835
|
function translateSchematicPoint(point, offset) {
|
|
3705
|
-
const sourceToSheetTransform =
|
|
3706
|
-
return
|
|
3836
|
+
const sourceToSheetTransform = translate4(offset.x, offset.y);
|
|
3837
|
+
return applyToPoint8(sourceToSheetTransform, point);
|
|
3707
3838
|
}
|
|
3708
3839
|
|
|
3709
3840
|
// lib/schematic/document/translateSchematicElement.ts
|
|
@@ -3932,9 +4063,9 @@ function appendConnectedPath({
|
|
|
3932
4063
|
// lib/pcb/geometry/createOctagonPoints.ts
|
|
3933
4064
|
import {
|
|
3934
4065
|
applyToPoints,
|
|
3935
|
-
compose as
|
|
3936
|
-
rotateDEG as
|
|
3937
|
-
translate as
|
|
4066
|
+
compose as compose3,
|
|
4067
|
+
rotateDEG as rotateDEG3,
|
|
4068
|
+
translate as translate5
|
|
3938
4069
|
} from "transformation-matrix";
|
|
3939
4070
|
function createOctagonPoints({
|
|
3940
4071
|
x,
|
|
@@ -3956,9 +4087,9 @@ function createOctagonPoints({
|
|
|
3956
4087
|
{ x: -halfWidth, y: halfHeight - chamfer },
|
|
3957
4088
|
{ x: -halfWidth, y: -halfHeight + chamfer }
|
|
3958
4089
|
];
|
|
3959
|
-
const localToPcbTransform =
|
|
3960
|
-
|
|
3961
|
-
|
|
4090
|
+
const localToPcbTransform = compose3(
|
|
4091
|
+
translate5(x, y),
|
|
4092
|
+
rotateDEG3(ccwRotationDegrees)
|
|
3962
4093
|
);
|
|
3963
4094
|
return applyToPoints(localToPcbTransform, points);
|
|
3964
4095
|
}
|
|
@@ -4802,10 +4933,10 @@ import {
|
|
|
4802
4933
|
import { normalizeAltiumAngle } from "altiumts";
|
|
4803
4934
|
|
|
4804
4935
|
// lib/pcb/pads/getRotatedHoleOffset.ts
|
|
4805
|
-
import { applyToPoint as
|
|
4936
|
+
import { applyToPoint as applyToPoint9, rotateDEG as rotateDEG4 } from "transformation-matrix";
|
|
4806
4937
|
function getRotatedHoleOffset(geometry) {
|
|
4807
|
-
const padToPcbTransform =
|
|
4808
|
-
return
|
|
4938
|
+
const padToPcbTransform = rotateDEG4(geometry.ccwRotationDegrees);
|
|
4939
|
+
return applyToPoint9(padToPcbTransform, {
|
|
4809
4940
|
x: geometry.holeOffsetXMils,
|
|
4810
4941
|
y: geometry.holeOffsetYMils
|
|
4811
4942
|
});
|