altium-to-circuit-json 0.0.71 → 0.0.72
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 +103 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3023,6 +3023,54 @@ function convertComponentPin({
|
|
|
3023
3023
|
};
|
|
3024
3024
|
}
|
|
3025
3025
|
|
|
3026
|
+
// lib/schematic/components/convertOwnedCustomComponentBody.ts
|
|
3027
|
+
import {
|
|
3028
|
+
AltiumSchEllipseRecord,
|
|
3029
|
+
AltiumSchEllipticalArcRecord,
|
|
3030
|
+
AltiumSchPolygonRecord,
|
|
3031
|
+
AltiumSchPolylineRecord
|
|
3032
|
+
} from "altiumts";
|
|
3033
|
+
|
|
3034
|
+
// lib/schematic/components/convertOwnedComponentRecords.ts
|
|
3035
|
+
import {
|
|
3036
|
+
AltiumSchImageRecord as AltiumSchImageRecord2,
|
|
3037
|
+
AltiumSchPinRecord
|
|
3038
|
+
} from "altiumts";
|
|
3039
|
+
function convertOwnedComponentRecords({
|
|
3040
|
+
ownedRecords,
|
|
3041
|
+
schematicComponentId
|
|
3042
|
+
}, context) {
|
|
3043
|
+
const records = context.document.records;
|
|
3044
|
+
const renderingContext = {
|
|
3045
|
+
document: context.document,
|
|
3046
|
+
records,
|
|
3047
|
+
scale: context.options.scale,
|
|
3048
|
+
sheetRecord: records.find((record) => record.recordKind === "31")
|
|
3049
|
+
};
|
|
3050
|
+
return ownedRecords.flatMap((record) => {
|
|
3051
|
+
if (record instanceof AltiumSchImageRecord2) return [];
|
|
3052
|
+
const index = records.indexOf(record);
|
|
3053
|
+
if (index < 0) return [];
|
|
3054
|
+
const elements = convertSchematicRecord(
|
|
3055
|
+
{
|
|
3056
|
+
index,
|
|
3057
|
+
options: {
|
|
3058
|
+
includeHidden: context.options.includeHidden,
|
|
3059
|
+
includeText: record instanceof AltiumSchPinRecord ? false : context.options.includeText
|
|
3060
|
+
},
|
|
3061
|
+
record
|
|
3062
|
+
},
|
|
3063
|
+
renderingContext
|
|
3064
|
+
);
|
|
3065
|
+
return elements.map(
|
|
3066
|
+
(element) => element.type === "schematic_text" ? element : {
|
|
3067
|
+
...element,
|
|
3068
|
+
schematic_component_id: schematicComponentId
|
|
3069
|
+
}
|
|
3070
|
+
);
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3026
3074
|
// lib/schematic/rendering/convertSchematicArcToPath.ts
|
|
3027
3075
|
import {
|
|
3028
3076
|
applyToPoint as applyToPoint7,
|
|
@@ -3064,46 +3112,42 @@ function convertSchematicArcToPath(schematicArc) {
|
|
|
3064
3112
|
};
|
|
3065
3113
|
}
|
|
3066
3114
|
|
|
3067
|
-
// lib/schematic/components/
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
}, context) {
|
|
3076
|
-
const records = context.document.records;
|
|
3077
|
-
const renderingContext = {
|
|
3078
|
-
document: context.document,
|
|
3079
|
-
records,
|
|
3080
|
-
scale: context.options.scale,
|
|
3081
|
-
sheetRecord: records.find((record) => record.recordKind === "31")
|
|
3082
|
-
};
|
|
3083
|
-
return ownedRecords.flatMap((record) => {
|
|
3084
|
-
if (record instanceof AltiumSchImageRecord2) return [];
|
|
3085
|
-
const index = records.indexOf(record);
|
|
3086
|
-
if (index < 0) return [];
|
|
3087
|
-
const elements = convertSchematicRecord(
|
|
3088
|
-
{
|
|
3089
|
-
index,
|
|
3090
|
-
options: {
|
|
3091
|
-
includeHidden: context.options.includeHidden,
|
|
3092
|
-
includeText: record instanceof AltiumSchPinRecord ? false : context.options.includeText
|
|
3093
|
-
},
|
|
3094
|
-
record
|
|
3095
|
-
},
|
|
3096
|
-
renderingContext
|
|
3097
|
-
);
|
|
3098
|
-
return elements.map(
|
|
3099
|
-
(element) => element.type === "schematic_text" ? element : {
|
|
3100
|
-
...element,
|
|
3101
|
-
schematic_component_id: schematicComponentId
|
|
3102
|
-
}
|
|
3103
|
-
);
|
|
3115
|
+
// lib/schematic/components/prepareOwnedComponentBodyElements.ts
|
|
3116
|
+
function prepareOwnedComponentBodyElements(elements) {
|
|
3117
|
+
return elements.map(
|
|
3118
|
+
(element) => element.type === "schematic_arc" ? convertSchematicArcToPath(element) : element
|
|
3119
|
+
).sort((left, right) => {
|
|
3120
|
+
const leftIsFilled = "is_filled" in left && left.is_filled === true ? 1 : 0;
|
|
3121
|
+
const rightIsFilled = "is_filled" in right && right.is_filled === true ? 1 : 0;
|
|
3122
|
+
return rightIsFilled - leftIsFilled;
|
|
3104
3123
|
});
|
|
3105
3124
|
}
|
|
3106
3125
|
|
|
3126
|
+
// lib/schematic/components/convertOwnedCustomComponentBody.ts
|
|
3127
|
+
function convertOwnedCustomComponentBody({
|
|
3128
|
+
identity,
|
|
3129
|
+
records
|
|
3130
|
+
}, context) {
|
|
3131
|
+
const hasEllipse = records.some(
|
|
3132
|
+
(record) => record instanceof AltiumSchEllipseRecord
|
|
3133
|
+
);
|
|
3134
|
+
const hasEllipticalArc = records.some(
|
|
3135
|
+
(record) => record instanceof AltiumSchEllipticalArcRecord
|
|
3136
|
+
);
|
|
3137
|
+
const hasPolygon = records.some(
|
|
3138
|
+
(record) => record instanceof AltiumSchPolygonRecord || record instanceof AltiumSchPolylineRecord
|
|
3139
|
+
);
|
|
3140
|
+
if (!hasEllipse || !hasEllipticalArc || !hasPolygon) return void 0;
|
|
3141
|
+
const ownedElements = convertOwnedComponentRecords(
|
|
3142
|
+
{
|
|
3143
|
+
ownedRecords: records,
|
|
3144
|
+
schematicComponentId: identity.schematicComponentId
|
|
3145
|
+
},
|
|
3146
|
+
context
|
|
3147
|
+
);
|
|
3148
|
+
return prepareOwnedComponentBodyElements(ownedElements);
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3107
3151
|
// lib/schematic/components/convertOwnedLogicGateBody.ts
|
|
3108
3152
|
function convertOwnedLogicGateBody({
|
|
3109
3153
|
identity,
|
|
@@ -3131,18 +3175,25 @@ function convertOwnedLogicGateBody({
|
|
|
3131
3175
|
if (!ownedElements.some((element) => element.type === "schematic_arc")) {
|
|
3132
3176
|
return void 0;
|
|
3133
3177
|
}
|
|
3134
|
-
return ownedElements
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3178
|
+
return prepareOwnedComponentBodyElements(ownedElements);
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
// lib/schematic/components/convertOwnedComponentBody.ts
|
|
3182
|
+
function convertOwnedComponentBody({
|
|
3183
|
+
identity,
|
|
3184
|
+
pins,
|
|
3185
|
+
records,
|
|
3186
|
+
visibleSymbolLabels
|
|
3187
|
+
}, context) {
|
|
3188
|
+
return convertOwnedLogicGateBody(
|
|
3189
|
+
{ identity, pins, records, visibleSymbolLabels },
|
|
3190
|
+
context
|
|
3191
|
+
) ?? convertOwnedCustomComponentBody({ identity, records }, context);
|
|
3141
3192
|
}
|
|
3142
3193
|
|
|
3143
3194
|
// lib/schematic/components/getComponentBodyBounds.ts
|
|
3144
3195
|
import {
|
|
3145
|
-
AltiumSchEllipseRecord,
|
|
3196
|
+
AltiumSchEllipseRecord as AltiumSchEllipseRecord2,
|
|
3146
3197
|
AltiumSchPinRecord as AltiumSchPinRecord2,
|
|
3147
3198
|
AltiumSchRectangleRecord,
|
|
3148
3199
|
getSchematicRecordPoints as getSchematicRecordPoints6
|
|
@@ -3162,7 +3213,7 @@ function getComponentBodyBounds(records, portPoints) {
|
|
|
3162
3213
|
const corner = getCorner(record);
|
|
3163
3214
|
if (location && corner) points.push(location, corner);
|
|
3164
3215
|
points.push(...getSchematicRecordPoints6(record));
|
|
3165
|
-
if (record instanceof
|
|
3216
|
+
if (record instanceof AltiumSchEllipseRecord2 && location) {
|
|
3166
3217
|
const radiusX = Math.abs(
|
|
3167
3218
|
getCoordinateOrFallback({ record, key: "RADIUS", fallback: 0 })
|
|
3168
3219
|
);
|
|
@@ -3637,11 +3688,11 @@ function convertComponent({
|
|
|
3637
3688
|
libraryReference: identity.libraryReference,
|
|
3638
3689
|
ports: componentPorts
|
|
3639
3690
|
});
|
|
3640
|
-
const
|
|
3691
|
+
const ownedComponentBody = symbolSelection ? void 0 : convertOwnedComponentBody(
|
|
3641
3692
|
{ identity, pins, records: visibleOwnedRecords, visibleSymbolLabels },
|
|
3642
3693
|
context
|
|
3643
3694
|
);
|
|
3644
|
-
const
|
|
3695
|
+
const hasOwnedComponentBody = ownedComponentBody !== void 0;
|
|
3645
3696
|
const center = scalePoint(getBoundsCenter(bodyBounds), options.scale);
|
|
3646
3697
|
const size = symbolSelection ? { ...symbolSelection.symbol.size } : {
|
|
3647
3698
|
height: Math.max(
|
|
@@ -3659,7 +3710,7 @@ function convertComponent({
|
|
|
3659
3710
|
const pinEdgeElements = createComponentPinEdgeElements(
|
|
3660
3711
|
{
|
|
3661
3712
|
componentPorts,
|
|
3662
|
-
includeNumericDesignators:
|
|
3713
|
+
includeNumericDesignators: hasOwnedComponentBody,
|
|
3663
3714
|
pins
|
|
3664
3715
|
},
|
|
3665
3716
|
context
|
|
@@ -3673,12 +3724,12 @@ function convertComponent({
|
|
|
3673
3724
|
]
|
|
3674
3725
|
),
|
|
3675
3726
|
...pinEdgeElements,
|
|
3676
|
-
...
|
|
3727
|
+
...ownedComponentBody ?? []
|
|
3677
3728
|
);
|
|
3678
3729
|
const schematicComponent = {
|
|
3679
3730
|
type: "schematic_component",
|
|
3680
3731
|
center,
|
|
3681
|
-
is_box_with_pins: !
|
|
3732
|
+
is_box_with_pins: !hasOwnedComponentBody,
|
|
3682
3733
|
schematic_component_id: identity.schematicComponentId,
|
|
3683
3734
|
schematic_sheet_id: options.schematicSheetId,
|
|
3684
3735
|
size,
|
|
@@ -3687,7 +3738,7 @@ function convertComponent({
|
|
|
3687
3738
|
...symbolSelection ? { symbol_name: symbolSelection.name } : {}
|
|
3688
3739
|
};
|
|
3689
3740
|
elements.push(schematicComponent);
|
|
3690
|
-
if (!symbolSelection && !
|
|
3741
|
+
if (!symbolSelection && !hasOwnedComponentBody && options.includeText !== false) {
|
|
3691
3742
|
addComponentFallbackText({
|
|
3692
3743
|
componentIndex,
|
|
3693
3744
|
designator: identity.designator,
|