Skip to content

Assembly

This module defines data models for Assembly entities retrieved from Onshape REST API responses.

The data models are implemented as Pydantic BaseModel classes, which are used to

1. Parse JSON responses from the API into Python objects.
2. Validate the structure and types of the JSON responses.
3. Provide type hints for better code clarity and autocompletion.

These models ensure that the data received from the API adheres to the expected format and types, facilitating easier and safer manipulation of the data within the application.

Models
  • Occurrence: Represents an occurrence of a part or sub-assembly within an assembly.
  • Part: Represents a part within an assembly, including its properties and configuration.
  • PartInstance: Represents an instance of a part within an assembly.
  • AssemblyInstance: Represents an instance of an assembly within another assembly.
  • AssemblyFeature: Represents a feature within an assembly, such as a mate or pattern.
  • Pattern: Represents a pattern feature within an assembly, defining repeated instances of parts or sub-assemblies.
  • SubAssembly: Represents a sub-assembly within a larger assembly.
  • RootAssembly: Represents the root assembly, which is the top-level assembly containing all parts and sub-assemblies.
  • Assembly: Represents the overall assembly, including all parts, sub-assemblies, and features.
Supplementary models
  • IDBase: Base model providing common attributes for Part, SubAssembly, and AssemblyInstance models.
  • MatedCS: Represents a coordinate system used for mating parts within an assembly.
  • MatedEntity: Represents an entity that is mated within an assembly, including its coordinate system.
  • MateRelationMate: Represents a mate relation within an assembly, defining how parts or sub-assemblies are connected.
  • MateGroupFeatureOccurrence: Represents an occurrence of a mate group feature within an assembly.
  • MateGroupFeatureData: Represents data for a mate group feature within an assembly.
  • MateConnectorFeatureData: Represents data for a mate connector feature within an assembly.
  • MateRelationFeatureData: Represents data for a mate relation feature within an assembly.
  • MateFeatureData: Represents data for a mate feature within an assembly.
Enum
  • InstanceType: Enumerates the types of instances in an assembly, e.g. PART, ASSEMBLY.
  • MateType: Enumerates the type of mate between two parts or assemblies, e.g. SLIDER, CYLINDRICAL, REVOLUTE, etc.
  • RelationType: Enumerates the type of mate relation between two parts or assemblies, e.g. LINEAR, GEAR, SCREW, etc.
  • AssemblyFeatureType: Enumerates the type of assembly feature, e.g. mate, mateRelation, mateGroup, mateConnector

Assembly

Bases: BaseModel

Represents the overall assembly, including all parts, sub-assemblies, and features.

JSON
    {
        "rootAssembly": {
            "instances": [],
            "patterns": [],
            "features": [],
            "occurrences": [],
            "fullConfiguration": "default",
            "configuration": "default",
            "documentId": "a1c1addf75444f54b504f25c",
            "elementId": "0b0c209535554345432581fe",
            "documentMicroversion": "349f6413cafefe8fb4ab3b07"
        },
        "subAssemblies": [],
        "parts": [],
        "partStudioFeatures": []
    }

Attributes:

Name Type Description
rootAssembly RootAssembly

The root assembly in the document.

subAssemblies list[SubAssembly]

A list of sub-assemblies in the document.

parts list[Part]

A list of parts in the document.

partStudioFeatures list[dict]

A list of part studio features in the document.

Custom Attributes

document (Union[Document, None]): The document object associated with the assembly. Defaults to None. name (Union[str, None]): The name of the assembly. Defaults to None.

Examples:

>>> Assembly(
...     rootAssembly=RootAssembly(
...         instances=[...],
...         patterns=[...],
...         features=[...],
...         occurrences=[...],
...         fullConfiguration="default",
...         configuration="default",
...         documentId="a1c1addf75444f54b504f25c",
...         elementId="0b0c209535554345432581fe",
...         documentMicroversion="349f6413cafefe8fb4ab3b07",
...     ),
...     subAssemblies=[...],
...     parts=[...],
...     partStudioFeatures=[...],
... )
Assembly(
    rootAssembly=RootAssembly(
        instances=[...],
        patterns=[...],
        features=[...],
        occurrences=[...],
        fullConfiguration="default",
        configuration="default",
        documentId="a1c1addf75444f54b504f25c",
        elementId="0b0c209535554345432581fe",
        documentMicroversion="349f6413cafefe8fb4ab3b07",
    ),
    subAssemblies=[...],
    parts=[...],
    partStudioFeatures=[...],
)
Source code in onshape_robotics_toolkit\models\assembly.py
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
class Assembly(BaseModel):
    """
    Represents the overall assembly, including all parts, sub-assemblies, and features.

    JSON:
        ```json
            {
                "rootAssembly": {
                    "instances": [],
                    "patterns": [],
                    "features": [],
                    "occurrences": [],
                    "fullConfiguration": "default",
                    "configuration": "default",
                    "documentId": "a1c1addf75444f54b504f25c",
                    "elementId": "0b0c209535554345432581fe",
                    "documentMicroversion": "349f6413cafefe8fb4ab3b07"
                },
                "subAssemblies": [],
                "parts": [],
                "partStudioFeatures": []
            }
        ```

    Attributes:
        rootAssembly (RootAssembly): The root assembly in the document.
        subAssemblies (list[SubAssembly]): A list of sub-assemblies in the document.
        parts (list[Part]): A list of parts in the document.
        partStudioFeatures (list[dict]): A list of part studio features in the document.

    Custom Attributes:
        document (Union[Document, None]): The document object associated with the assembly. Defaults to None.
        name (Union[str, None]): The name of the assembly. Defaults to None.


    Examples:
        >>> Assembly(
        ...     rootAssembly=RootAssembly(
        ...         instances=[...],
        ...         patterns=[...],
        ...         features=[...],
        ...         occurrences=[...],
        ...         fullConfiguration="default",
        ...         configuration="default",
        ...         documentId="a1c1addf75444f54b504f25c",
        ...         elementId="0b0c209535554345432581fe",
        ...         documentMicroversion="349f6413cafefe8fb4ab3b07",
        ...     ),
        ...     subAssemblies=[...],
        ...     parts=[...],
        ...     partStudioFeatures=[...],
        ... )
        Assembly(
            rootAssembly=RootAssembly(
                instances=[...],
                patterns=[...],
                features=[...],
                occurrences=[...],
                fullConfiguration="default",
                configuration="default",
                documentId="a1c1addf75444f54b504f25c",
                elementId="0b0c209535554345432581fe",
                documentMicroversion="349f6413cafefe8fb4ab3b07",
            ),
            subAssemblies=[...],
            parts=[...],
            partStudioFeatures=[...],
        )
    """

    rootAssembly: RootAssembly = Field(..., description="The root assembly in the document.")
    subAssemblies: list[SubAssembly] = Field(..., description="A list of sub-assemblies in the document.")
    parts: list[Part] = Field(..., description="A list of parts in the document.")
    partStudioFeatures: list[dict] = Field(..., description="A list of part studio features in the document.")

    document: Union[Document, None] = Field(None, description="The document associated with the assembly.")
    name: Union[str, None] = Field(None, description="The name of the assembly.")

AssemblyFeature

Bases: BaseModel

Represents a feature within an assembly, such as a mate or pattern.

JSON
    {
    "id": "Mw+URe/Uaxx5gIdlu",
    "suppressed": false,
    "featureType": "mate",
    "featureData": {
        "matedEntities" :
        [
            {
                "matedOccurrence" : [ "MDUJyqGNo7JJll+/h" ],
                "matedCS" :
                {
                    "xAxis" : [ 1.0, 0.0, 0.0 ],
                    "yAxis" : [ 0.0, 0.0, -1.0 ],
                    "zAxis" : [ 0.0, 1.0, 0.0 ],
                    "origin" : [ 0.0, -0.0505, 0.0 ]
                }
            }, {
                "matedOccurrence" : [ "MwoBIsds8rn1/0QXA" ],
                "matedCS" :
                {
                    "xAxis" : [ 0.8660254037844387, 0.0, -0.49999999999999994 ],
                    "yAxis" : [ -0.49999999999999994, 0.0, -0.8660254037844387 ],
                    "zAxis" : [ 0.0, 1.0, 0.0 ],
                    "origin" : [ 0.0, -0.0505, 0.0 ]
                }
            }
        ],
        "mateType" : "FASTENED",
        "name" : "Fastened 1"
        }
    }

Attributes:

Name Type Description
id str

The unique identifier of the feature.

suppressed bool

Indicates if the feature is suppressed.

featureType AssemblyFeatureType

The type of the feature.

featureData Union[MateGroupFeatureData, MateConnectorFeatureData, MateRelationFeatureData, MateFeatureData]

Data associated with the assembly feature.

Examples:

>>> AssemblyFeature(
...     id="Mw+URe/Uaxx5gIdlu",
...     suppressed=False,
...     featureType=AssemblyFeatureType.MATE,
...     featureData=MateFeatureData(
...         matedEntities=[...],
...         mateType=MateType.FASTENED,
...         name="Fastened 1",
...     ),
... )
AssemblyFeature(
    id="Mw+URe/Uaxx5gIdlu",
    suppressed=False,
    featureType=AssemblyFeatureType.MATE,
    featureData=MateFeatureData(
        matedEntities=[...],
        mateType=MateType.FASTENED,
        name="Fastened 1"
    )
)
Source code in onshape_robotics_toolkit\models\assembly.py
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
class AssemblyFeature(BaseModel):
    """
    Represents a feature within an assembly, such as a mate or pattern.

    JSON:
        ```json
            {
            "id": "Mw+URe/Uaxx5gIdlu",
            "suppressed": false,
            "featureType": "mate",
            "featureData": {
                "matedEntities" :
                [
                    {
                        "matedOccurrence" : [ "MDUJyqGNo7JJll+/h" ],
                        "matedCS" :
                        {
                            "xAxis" : [ 1.0, 0.0, 0.0 ],
                            "yAxis" : [ 0.0, 0.0, -1.0 ],
                            "zAxis" : [ 0.0, 1.0, 0.0 ],
                            "origin" : [ 0.0, -0.0505, 0.0 ]
                        }
                    }, {
                        "matedOccurrence" : [ "MwoBIsds8rn1/0QXA" ],
                        "matedCS" :
                        {
                            "xAxis" : [ 0.8660254037844387, 0.0, -0.49999999999999994 ],
                            "yAxis" : [ -0.49999999999999994, 0.0, -0.8660254037844387 ],
                            "zAxis" : [ 0.0, 1.0, 0.0 ],
                            "origin" : [ 0.0, -0.0505, 0.0 ]
                        }
                    }
                ],
                "mateType" : "FASTENED",
                "name" : "Fastened 1"
                }
            }
        ```

    Attributes:
        id (str): The unique identifier of the feature.
        suppressed (bool): Indicates if the feature is suppressed.
        featureType (AssemblyFeatureType): The type of the feature.
        featureData (Union[MateGroupFeatureData, MateConnectorFeatureData, MateRelationFeatureData, MateFeatureData]):
            Data associated with the assembly feature.

    Examples:
        >>> AssemblyFeature(
        ...     id="Mw+URe/Uaxx5gIdlu",
        ...     suppressed=False,
        ...     featureType=AssemblyFeatureType.MATE,
        ...     featureData=MateFeatureData(
        ...         matedEntities=[...],
        ...         mateType=MateType.FASTENED,
        ...         name="Fastened 1",
        ...     ),
        ... )
        AssemblyFeature(
            id="Mw+URe/Uaxx5gIdlu",
            suppressed=False,
            featureType=AssemblyFeatureType.MATE,
            featureData=MateFeatureData(
                matedEntities=[...],
                mateType=MateType.FASTENED,
                name="Fastened 1"
            )
        )
    """

    id: str = Field(..., description="The unique identifier of the feature.")
    suppressed: bool = Field(..., description="Indicates if the feature is suppressed.")
    featureType: AssemblyFeatureType = Field(..., description="The type of the feature.")
    featureData: Union[MateGroupFeatureData, MateConnectorFeatureData, MateRelationFeatureData, MateFeatureData] = (
        Field(..., description="Data associated with the assembly feature.")
    )

AssemblyFeatureType

Bases: str, Enum

Enumerates the type of assembly feature, e.g. mate, mateRelation, mateGroup, mateConnector

Attributes:

Name Type Description
MATE str

Represents a mate feature.

MATERELATION str

Represents a mate relation feature.

MATEGROUP str

Represents a mate group feature.

MATECONNECTOR str

Represents a mate connector feature.

Examples:

>>> AssemblyFeatureType.MATE
'mate'
>>> AssemblyFeatureType.MATERELATION
'mateRelation'
Source code in onshape_robotics_toolkit\models\assembly.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
class AssemblyFeatureType(str, Enum):
    """
    Enumerates the type of assembly feature, e.g. mate, mateRelation, mateGroup, mateConnector

    Attributes:
        MATE (str): Represents a mate feature.
        MATERELATION (str): Represents a mate relation feature.
        MATEGROUP (str): Represents a mate group feature.
        MATECONNECTOR (str): Represents a mate connector feature.

    Examples:
        >>> AssemblyFeatureType.MATE
        'mate'
        >>> AssemblyFeatureType.MATERELATION
        'mateRelation'
    """

    MATE = "mate"
    MATERELATION = "mateRelation"
    MATEGROUP = "mateGroup"
    MATECONNECTOR = "mateConnector"

AssemblyInstance

Bases: IDBase

Represents an instance of an assembly within another assembly.

JSON
    {
        "id": "Mon18P7LPP8A9STk+",
        "type": "Assembly",
        "name": "subAssembly",
        "suppressed": false,
        "fullConfiguration": "default",
        "configuration": "default",
        "documentId": "a1c1addf75444f54b504f25c",
        "elementId": "f0b3a4afab120f778a4037df",
        "documentMicroversion": "349f6413cafefe8fb4ab3b07"
    }

Attributes:

Name Type Description
id str

The unique identifier for the assembly instance.

type InstanceType

The type of the instance, must be 'Assembly'.

name str

The name of the assembly instance.

suppressed bool

Indicates if the assembly instance is suppressed.

Examples:

>>> AssemblyInstance(
...     id="Mon18P7LPP8A9STk+",
...     type=InstanceType.ASSEMBLY,
...     name="subAssembly",
...     suppressed=False,
... )
AssemblyInstance(
    id="Mon18P7LPP8A9STk+",
    type=InstanceType.ASSEMBLY,
    name="subAssembly",
    suppressed=False,
)
Source code in onshape_robotics_toolkit\models\assembly.py
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
class AssemblyInstance(IDBase):
    """
    Represents an instance of an assembly within another assembly.

    JSON:
        ```json
            {
                "id": "Mon18P7LPP8A9STk+",
                "type": "Assembly",
                "name": "subAssembly",
                "suppressed": false,
                "fullConfiguration": "default",
                "configuration": "default",
                "documentId": "a1c1addf75444f54b504f25c",
                "elementId": "f0b3a4afab120f778a4037df",
                "documentMicroversion": "349f6413cafefe8fb4ab3b07"
            }
        ```

    Attributes:
        id (str): The unique identifier for the assembly instance.
        type (InstanceType): The type of the instance, must be 'Assembly'.
        name (str): The name of the assembly instance.
        suppressed (bool): Indicates if the assembly instance is suppressed.

    Examples:
        >>> AssemblyInstance(
        ...     id="Mon18P7LPP8A9STk+",
        ...     type=InstanceType.ASSEMBLY,
        ...     name="subAssembly",
        ...     suppressed=False,
        ... )
        AssemblyInstance(
            id="Mon18P7LPP8A9STk+",
            type=InstanceType.ASSEMBLY,
            name="subAssembly",
            suppressed=False,
        )
    """

    id: str = Field(..., description="The unique identifier for the assembly instance.")
    type: InstanceType = Field(..., description="The type of the instance, must be 'Assembly'.")
    name: str = Field(..., description="The name of the assembly instance.")
    suppressed: bool = Field(..., description="Indicates if the assembly instance is suppressed.")

    isRigid: bool = Field(
        False,
        description="Indicates if the assembly instance is a rigid assembly, i.e., \
        a sub-assembly with no degrees of freedom.",
    )

    @field_validator("type")
    def check_type(cls, v: InstanceType) -> InstanceType:
        """
        Validates that the type is 'Assembly'.

        Args:
            v (InstanceType): The type to validate.

        Returns:
            InstanceType: The validated type.
        """
        if v != InstanceType.ASSEMBLY:
            raise ValueError("Type must be Assembly")

        return v

check_type(v)

Validates that the type is 'Assembly'.

Parameters:

Name Type Description Default
v InstanceType

The type to validate.

required

Returns:

Name Type Description
InstanceType InstanceType

The validated type.

Source code in onshape_robotics_toolkit\models\assembly.py
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
@field_validator("type")
def check_type(cls, v: InstanceType) -> InstanceType:
    """
    Validates that the type is 'Assembly'.

    Args:
        v (InstanceType): The type to validate.

    Returns:
        InstanceType: The validated type.
    """
    if v != InstanceType.ASSEMBLY:
        raise ValueError("Type must be Assembly")

    return v

IDBase

Bases: BaseModel

Base model providing common attributes for Part, SubAssembly, and AssemblyInstance models.

JSON
    {
        "fullConfiguration" : "default",
        "configuration" : "default",
        "documentId" : "a1c1addf75444f54b504f25c",
        "elementId" : "0b0c209535554345432581fe",
        "documentMicroversion" : "12fabf866bef5a9114d8c4d2"
    }

Attributes:

Name Type Description
fullConfiguration str

The full configuration of the entity.

configuration str

The configuration of the entity.

documentId str

The unique identifier of the entity.

elementId str

The unique identifier of the entity.

documentMicroversion str

The microversion of the document.

Source code in onshape_robotics_toolkit\models\assembly.py
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
class IDBase(BaseModel):
    """
    Base model providing common attributes for Part, SubAssembly, and AssemblyInstance models.

    JSON:
        ```json
            {
                "fullConfiguration" : "default",
                "configuration" : "default",
                "documentId" : "a1c1addf75444f54b504f25c",
                "elementId" : "0b0c209535554345432581fe",
                "documentMicroversion" : "12fabf866bef5a9114d8c4d2"
            }
        ```

    Attributes:
        fullConfiguration (str): The full configuration of the entity.
        configuration (str): The configuration of the entity.
        documentId (str): The unique identifier of the entity.
        elementId (str): The unique identifier of the entity.
        documentMicroversion (str): The microversion of the document.
    """

    fullConfiguration: str = Field(..., description="The full configuration of the entity.")
    configuration: str = Field(..., description="The configuration of the entity.")
    documentId: str = Field(..., description="The unique identifier of the entity.")
    elementId: str = Field(..., description="The unique identifier of the entity.")
    documentMicroversion: str = Field(..., description="The microversion of the document.")

    @field_validator("documentId", "elementId", "documentMicroversion")
    def check_ids(cls, v: str) -> str:
        """
        Validates that the ID fields have exactly 24 characters.

        Args:
            v (str): The ID field to validate.

        Returns:
            str: The validated ID field.

        Raises:
            ValueError: If the ID field does not contain exactly 24 characters.
        """
        if len(v) != 24:
            raise ValueError("DocumentId must have 24 characters")

        return v

    @property
    def uid(self) -> str:
        """
        Generates a unique identifier for the part.

        Returns:
            str: The unique identifier generated from documentId, documentMicroversion,
                elementId, and fullConfiguration.
        """
        return generate_uid([self.documentId, self.documentMicroversion, self.elementId, self.fullConfiguration])

uid: str property

Generates a unique identifier for the part.

Returns:

Name Type Description
str str

The unique identifier generated from documentId, documentMicroversion, elementId, and fullConfiguration.

check_ids(v)

Validates that the ID fields have exactly 24 characters.

Parameters:

Name Type Description Default
v str

The ID field to validate.

required

Returns:

Name Type Description
str str

The validated ID field.

Raises:

Type Description
ValueError

If the ID field does not contain exactly 24 characters.

Source code in onshape_robotics_toolkit\models\assembly.py
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
@field_validator("documentId", "elementId", "documentMicroversion")
def check_ids(cls, v: str) -> str:
    """
    Validates that the ID fields have exactly 24 characters.

    Args:
        v (str): The ID field to validate.

    Returns:
        str: The validated ID field.

    Raises:
        ValueError: If the ID field does not contain exactly 24 characters.
    """
    if len(v) != 24:
        raise ValueError("DocumentId must have 24 characters")

    return v

InstanceType

Bases: str, Enum

Enumerates the types of instances in an assembly, e.g. PART, ASSEMBLY.

Attributes:

Name Type Description
PART str

Represents a part instance.

ASSEMBLY str

Represents an assembly instance.

Examples:

>>> InstanceType.PART
'Part'
>>> InstanceType.ASSEMBLY
'Assembly'
Source code in onshape_robotics_toolkit\models\assembly.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class InstanceType(str, Enum):
    """
    Enumerates the types of instances in an assembly, e.g. PART, ASSEMBLY.

    Attributes:
        PART (str): Represents a part instance.
        ASSEMBLY (str): Represents an assembly instance.

    Examples:
        >>> InstanceType.PART
        'Part'
        >>> InstanceType.ASSEMBLY
        'Assembly'
    """

    PART = "Part"
    ASSEMBLY = "Assembly"

MateConnectorFeatureData

Bases: BaseModel

Represents data for a mate connector feature within an assembly.

JSON
    {
        "mateConnectorCS": {
            "xAxis": [1.0, 0.0, 0.0],
            "yAxis": [0.0, 0.0, -1.0],
            "zAxis": [0.0, 1.0, 0.0],
            "origin": [0.0, -0.0505, 0.0]
        },
        "occurrence": [
            "MplKLzV/4d+nqmD18"
        ],
        "name": "Mate connector 1"
    }

Attributes:

Name Type Description
mateConnectorCS MatedCS

The coordinate system used for the mate connector.

occurrence list[str]

A list of identifiers for the occurrences involved in the mate connector.

name str

The name of the mate connector feature.

Custom Attributes

id (str): The unique identifier of the feature.

Examples:

>>> MateConnectorFeatureData(
...     mateConnectorCS=MatedCS(
...         xAxis=[1.0, 0.0, 0.0],
...         yAxis=[0.0, 0.0, -1.0],
...         zAxis=[0.0, 1.0, 0.0],
...         origin=[0.0, -0.0505, 0.0],
...     ),
...     occurrence=["MplKLzV/4d+nqmD18"],
...     name="Mate connector 1",
... )
MateConnectorFeatureData(
    mateConnectorCS=MatedCS(
        xAxis=[1.0, 0.0, 0.0],
        yAxis=[0.0, 0.0, -1.0],
        zAxis=[0.0, 1.0, 0.0],
        origin=[0.0, -0.0505, 0.0]
    ),
    occurrence=["MplKLzV/4d+nqmD18"],
    name="Mate connector 1"
)
Source code in onshape_robotics_toolkit\models\assembly.py
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
class MateConnectorFeatureData(BaseModel):
    """
    Represents data for a mate connector feature within an assembly.

    JSON:
        ```json
            {
                "mateConnectorCS": {
                    "xAxis": [1.0, 0.0, 0.0],
                    "yAxis": [0.0, 0.0, -1.0],
                    "zAxis": [0.0, 1.0, 0.0],
                    "origin": [0.0, -0.0505, 0.0]
                },
                "occurrence": [
                    "MplKLzV/4d+nqmD18"
                ],
                "name": "Mate connector 1"
            }
        ```

    Attributes:
        mateConnectorCS (MatedCS): The coordinate system used for the mate connector.
        occurrence (list[str]): A list of identifiers for the occurrences involved in the mate connector.
        name (str): The name of the mate connector feature.

    Custom Attributes:
        id (str): The unique identifier of the feature.

    Examples:
        >>> MateConnectorFeatureData(
        ...     mateConnectorCS=MatedCS(
        ...         xAxis=[1.0, 0.0, 0.0],
        ...         yAxis=[0.0, 0.0, -1.0],
        ...         zAxis=[0.0, 1.0, 0.0],
        ...         origin=[0.0, -0.0505, 0.0],
        ...     ),
        ...     occurrence=["MplKLzV/4d+nqmD18"],
        ...     name="Mate connector 1",
        ... )
        MateConnectorFeatureData(
            mateConnectorCS=MatedCS(
                xAxis=[1.0, 0.0, 0.0],
                yAxis=[0.0, 0.0, -1.0],
                zAxis=[0.0, 1.0, 0.0],
                origin=[0.0, -0.0505, 0.0]
            ),
            occurrence=["MplKLzV/4d+nqmD18"],
            name="Mate connector 1"
        )
    """

    mateConnectorCS: MatedCS = Field(..., description="The coordinate system used for the mate connector.")
    occurrence: list[str] = Field(
        ..., description="A list of identifiers for the occurrences involved in the mate connector."
    )
    name: str = Field(..., description="The name of the mate connector feature.")

    id: str = Field(None, description="The unique identifier of the feature.")

MateFeatureData

Bases: BaseModel

Represents data for a mate feature within an assembly.

JSON
    {
        "matedEntities" :
        [
            {
                "matedOccurrence" : [ "MDUJyqGNo7JJll+/h" ],
                "matedCS" :
                {
                    "xAxis" : [ 1.0, 0.0, 0.0 ],
                    "yAxis" : [ 0.0, 0.0, -1.0 ],
                    "zAxis" : [ 0.0, 1.0, 0.0 ],
                    "origin" : [ 0.0, -0.0505, 0.0 ]
                }
            }, {
                "matedOccurrence" : [ "MwoBIsds8rn1/0QXA" ],
                "matedCS" :
                {
                    "xAxis" : [ 0.8660254037844387, 0.0, -0.49999999999999994 ],
                    "yAxis" : [ -0.49999999999999994, 0.0, -0.8660254037844387 ],
                    "zAxis" : [ 0.0, 1.0, 0.0 ],
                    "origin" : [ 0.0, -0.0505, 0.0 ]
                }
            }
        ],
        "mateType" : "FASTENED",
        "name" : "Fastened 1"
    }

Attributes:

Name Type Description
matedEntities list[MatedEntity]

A list of mated entities.

mateType MateType

The type of mate.

name str

The name of the mate feature.

Custom Attributes

id (str): The unique identifier of the feature.

Examples:

>>> MateFeatureData(
...     matedEntities=[...],
...     mateType=MateType.FASTENED,
...     name="Fastened 1",
... )
MateFeatureData(
    matedEntities=[...],
    mateType=MateType.FASTENED,
    name="Fastened 1"
)
Source code in onshape_robotics_toolkit\models\assembly.py
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
class MateFeatureData(BaseModel):
    """
    Represents data for a mate feature within an assembly.

    JSON:
        ```json
            {
                "matedEntities" :
                [
                    {
                        "matedOccurrence" : [ "MDUJyqGNo7JJll+/h" ],
                        "matedCS" :
                        {
                            "xAxis" : [ 1.0, 0.0, 0.0 ],
                            "yAxis" : [ 0.0, 0.0, -1.0 ],
                            "zAxis" : [ 0.0, 1.0, 0.0 ],
                            "origin" : [ 0.0, -0.0505, 0.0 ]
                        }
                    }, {
                        "matedOccurrence" : [ "MwoBIsds8rn1/0QXA" ],
                        "matedCS" :
                        {
                            "xAxis" : [ 0.8660254037844387, 0.0, -0.49999999999999994 ],
                            "yAxis" : [ -0.49999999999999994, 0.0, -0.8660254037844387 ],
                            "zAxis" : [ 0.0, 1.0, 0.0 ],
                            "origin" : [ 0.0, -0.0505, 0.0 ]
                        }
                    }
                ],
                "mateType" : "FASTENED",
                "name" : "Fastened 1"
            }
        ```

    Attributes:
        matedEntities (list[MatedEntity]): A list of mated entities.
        mateType (MateType): The type of mate.
        name (str): The name of the mate feature.

    Custom Attributes:
        id (str): The unique identifier of the feature.

    Examples:
        >>> MateFeatureData(
        ...     matedEntities=[...],
        ...     mateType=MateType.FASTENED,
        ...     name="Fastened 1",
        ... )
        MateFeatureData(
            matedEntities=[...],
            mateType=MateType.FASTENED,
            name="Fastened 1"
        )

    """

    class Config:
        arbitrary_types_allowed = True

    matedEntities: list[MatedEntity] = Field(..., description="A list of mated entities.")
    mateType: MateType = Field(..., description="The type of mate.")
    name: str = Field(..., description="The name of the mate feature.")

    id: str = Field(None, description="The unique identifier of the feature.")

MateGroupFeatureData

Bases: BaseModel

Represents data for a mate group feature within an assembly.

JSON
    {
        "occurrences": [
            {
                "occurrence": ["MplKLzV/4d+nqmD18"]
            }
        ],
        "name": "Mate group 1"
    }

Attributes:

Name Type Description
occurrences list[MateGroupFeatureOccurrence]

A list of occurrences in the mate group feature.

name str

The name of the mate group feature.

Custom Attributes

id (str): The unique identifier of the feature.

Examples:

>>> MateGroupFeatureData(
...     occurrences=[
...         MateGroupFeatureOccurrence(
...             occurrence=["MplKLzV/4d+nqmD18"],
...         )
...     ],
...     name="Mate group 1",
... )
MateGroupFeatureData(
    occurrences=[
        MateGroupFeatureOccurrence(
            occurrence=["MplKLzV/4d+nqmD18"]
        )
    ],
    name="Mate group 1"
)
Source code in onshape_robotics_toolkit\models\assembly.py
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
class MateGroupFeatureData(BaseModel):
    """
    Represents data for a mate group feature within an assembly.

    JSON:
        ```json
            {
                "occurrences": [
                    {
                        "occurrence": ["MplKLzV/4d+nqmD18"]
                    }
                ],
                "name": "Mate group 1"
            }
        ```

    Attributes:
        occurrences (list[MateGroupFeatureOccurrence]): A list of occurrences in the mate group feature.
        name (str): The name of the mate group feature.

    Custom Attributes:
        id (str): The unique identifier of the feature.

    Examples:
        >>> MateGroupFeatureData(
        ...     occurrences=[
        ...         MateGroupFeatureOccurrence(
        ...             occurrence=["MplKLzV/4d+nqmD18"],
        ...         )
        ...     ],
        ...     name="Mate group 1",
        ... )
        MateGroupFeatureData(
            occurrences=[
                MateGroupFeatureOccurrence(
                    occurrence=["MplKLzV/4d+nqmD18"]
                )
            ],
            name="Mate group 1"
        )
    """

    occurrences: list[MateGroupFeatureOccurrence] = Field(
        ..., description="A list of occurrences in the mate group feature."
    )
    name: str = Field(..., description="The name of the mate group feature.")

    id: str = Field(None, description="The unique identifier of the feature.")

MateGroupFeatureOccurrence

Bases: BaseModel

Represents an occurrence of a mate group feature within an assembly.

JSON
    {
        "occurrence": ["MplKLzV/4d+nqmD18"]
    }

Attributes:

Name Type Description
occurrence list[str]

A list of identifiers for the occurrences in the mate group feature.

Examples:

>>> MateGroupFeatureOccurrence(
...     occurrence=["MplKLzV/4d+nqmD18"],
... )
MateGroupFeatureOccurrence(
    occurrence=["MplKLzV/4d+nqmD18"]
)
Source code in onshape_robotics_toolkit\models\assembly.py
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
class MateGroupFeatureOccurrence(BaseModel):
    """
    Represents an occurrence of a mate group feature within an assembly.

    JSON:
        ```json
            {
                "occurrence": ["MplKLzV/4d+nqmD18"]
            }
        ```

    Attributes:
        occurrence (list[str]): A list of identifiers for the occurrences in the mate group feature.

    Examples:
        >>> MateGroupFeatureOccurrence(
        ...     occurrence=["MplKLzV/4d+nqmD18"],
        ... )
        MateGroupFeatureOccurrence(
            occurrence=["MplKLzV/4d+nqmD18"]
        )
    """

    occurrence: list[str] = Field(
        ..., description="A list of identifiers for the occurrences in the mate group feature."
    )

MateRelationFeatureData

Bases: BaseModel

Represents data for a mate relation feature within an assembly.

JSON
    {
        "relationType": "GEAR",
        "mates": [
            {
            "featureId": "S4/TgCRmQt1nIHHp",
            "occurrence": []
            },
            {
            "featureId": "QwaoOeXYPifsN7CP",
            "occurrence": []
            }
        ],
        "reverseDirection": false,
        "relationRatio": 1,
        "name": "Gear 1"
    }

Attributes:

Name Type Description
relationType RelationType

The type of mate relation.

mates list[MateRelationMate]

A list of mate relations.

reverseDirection bool

Indicates if the direction of the mate relation is reversed.

relationRatio Union[float, None]

The ratio of the GEAR mate relation. Defaults to None.

relationLength Union[float, None]

The length of the RACK_AND_PINION mate relation. Defaults to None.

name str

The name of the mate relation feature.

Custom Attributes

id (str): The unique identifier of the feature.

Examples:

>>> MateRelationFeatureData(
...     relationType=RelationType.GEAR,
...     mates=[...],
...     reverseDirection=False,
...     relationRatio=1,
...     name="Gear 1",
... )
MateRelationFeatureData(
    relationType=RelationType.GEAR,
    mates=[...],
    reverseDirection=False,
    relationRatio=1,
    name="Gear 1"
)
Source code in onshape_robotics_toolkit\models\assembly.py
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
class MateRelationFeatureData(BaseModel):
    """
    Represents data for a mate relation feature within an assembly.

    JSON:
        ```json
            {
                "relationType": "GEAR",
                "mates": [
                    {
                    "featureId": "S4/TgCRmQt1nIHHp",
                    "occurrence": []
                    },
                    {
                    "featureId": "QwaoOeXYPifsN7CP",
                    "occurrence": []
                    }
                ],
                "reverseDirection": false,
                "relationRatio": 1,
                "name": "Gear 1"
            }
        ```

    Attributes:
        relationType (RelationType): The type of mate relation.
        mates (list[MateRelationMate]): A list of mate relations.
        reverseDirection (bool): Indicates if the direction of the mate relation is reversed.
        relationRatio (Union[float, None]): The ratio of the GEAR mate relation. Defaults to None.
        relationLength (Union[float, None]): The length of the RACK_AND_PINION mate relation. Defaults to None.
        name (str): The name of the mate relation feature.

    Custom Attributes:
        id (str): The unique identifier of the feature.

    Examples:
        >>> MateRelationFeatureData(
        ...     relationType=RelationType.GEAR,
        ...     mates=[...],
        ...     reverseDirection=False,
        ...     relationRatio=1,
        ...     name="Gear 1",
        ... )
        MateRelationFeatureData(
            relationType=RelationType.GEAR,
            mates=[...],
            reverseDirection=False,
            relationRatio=1,
            name="Gear 1"
        )
    """

    relationType: RelationType = Field(..., description="The type of mate relation.")
    mates: list[MateRelationMate] = Field(..., description="A list of mate relations.")
    reverseDirection: bool = Field(..., description="Indicates if the direction of the mate relation is reversed.")
    relationRatio: Union[float, None] = Field(
        None, description="The ratio of the GEAR mate relation. Defaults to None."
    )
    relationLength: Union[float, None] = Field(
        None, description="The length of the RACK_AND_PINION mate relation. Defaults to None."
    )
    name: str = Field(..., description="The name of the mate relation feature.")

    id: str = Field(None, description="The unique identifier of the feature.")

MateRelationMate

Bases: BaseModel

Represents a mate relation within an assembly, defining how parts or sub-assemblies are connected.

JSON
    {
        "featureId": "S4/TgCRmQt1nIHHp",
        "occurrence": []
    }

Attributes:

Name Type Description
featureId str

The unique identifier of the mate feature.

occurrence list[str]

A list of identifiers for the occurrences involved in the mate relation.

Examples:

>>> MateRelationMate(
...     featureId="S4/TgCRmQt1nIHHp",
...     occurrence=[],
... )
MateRelationMate(
    featureId="S4/TgCRmQt1nIHHp",
    occurrence=[],
)
Source code in onshape_robotics_toolkit\models\assembly.py
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
class MateRelationMate(BaseModel):
    """
    Represents a mate relation within an assembly, defining how parts or sub-assemblies are connected.

    JSON:
        ```json
            {
                "featureId": "S4/TgCRmQt1nIHHp",
                "occurrence": []
            }
        ```

    Attributes:
        featureId (str): The unique identifier of the mate feature.
        occurrence (list[str]): A list of identifiers for the occurrences involved in the mate relation.

    Examples:
        >>> MateRelationMate(
        ...     featureId="S4/TgCRmQt1nIHHp",
        ...     occurrence=[],
        ... )
        MateRelationMate(
            featureId="S4/TgCRmQt1nIHHp",
            occurrence=[],
        )
    """

    featureId: str = Field(..., description="The unique identifier of the mate feature.")
    occurrence: list[str] = Field(
        ..., description="A list of identifiers for the occurrences involved in the mate relation."
    )

MateType

Bases: str, Enum

Enumerates the type of mate between two parts or assemblies, e.g. SLIDER, CYLINDRICAL, REVOLUTE, etc.

Attributes:

Name Type Description
SLIDER str

Represents a slider mate.

CYLINDRICAL str

Represents a cylindrical mate.

REVOLUTE str

Represents a revolute mate.

PIN_SLOT str

Represents a pin-slot mate.

PLANAR str

Represents a planar mate.

BALL str

Represents a ball mate.

FASTENED str

Represents a fastened mate.

PARALLEL str

Represents a parallel mate.

Examples:

>>> MateType.SLIDER
'SLIDER'
>>> MateType.CYLINDRICAL
'CYLINDRICAL'
Source code in onshape_robotics_toolkit\models\assembly.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
class MateType(str, Enum):
    """
    Enumerates the type of mate between two parts or assemblies, e.g. SLIDER, CYLINDRICAL, REVOLUTE, etc.

    Attributes:
        SLIDER (str): Represents a slider mate.
        CYLINDRICAL (str): Represents a cylindrical mate.
        REVOLUTE (str): Represents a revolute mate.
        PIN_SLOT (str): Represents a pin-slot mate.
        PLANAR (str): Represents a planar mate.
        BALL (str): Represents a ball mate.
        FASTENED (str): Represents a fastened mate.
        PARALLEL (str): Represents a parallel mate.

    Examples:
        >>> MateType.SLIDER
        'SLIDER'
        >>> MateType.CYLINDRICAL
        'CYLINDRICAL'
    """

    SLIDER = "SLIDER"
    CYLINDRICAL = "CYLINDRICAL"
    REVOLUTE = "REVOLUTE"
    PIN_SLOT = "PIN_SLOT"
    PLANAR = "PLANAR"
    BALL = "BALL"
    FASTENED = "FASTENED"
    PARALLEL = "PARALLEL"

MatedCS

Bases: BaseModel

Represents a coordinate system used for mating parts within an assembly.

JSON
    {
        "xAxis" : [ 1.0, 0.0, 0.0 ],
        "yAxis" : [ 0.0, 0.0, -1.0 ],
        "zAxis" : [ 0.0, 1.0, 0.0 ],
        "origin" : [ 0.0, -0.0505, 0.0 ]
    }

Attributes:

Name Type Description
xAxis list[float]

The x-axis vector of the coordinate system.

yAxis list[float]

The y-axis vector of the coordinate system.

zAxis list[float]

The z-axis vector of the coordinate system.

origin list[float]

The origin point of the coordinate system.

Examples:

>>> MatedCS(
...     xAxis=[1.0, 0.0, 0.0],
...     yAxis=[0.0, 0.0, -1.0],
...     zAxis=[0.0, 1.0, 0.0],
...     origin=[0.0, -0.0505, 0.0],
... )
MatedCS(
    xAxis=[1.0, 0.0, 0.0],
    yAxis=[0.0, 0.0, -1.0],
    zAxis=[0.0, 1.0, 0.0],
    origin=[0.0, -0.0505, 0.0]
)
Source code in onshape_robotics_toolkit\models\assembly.py
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
class MatedCS(BaseModel):
    """
    Represents a coordinate system used for mating parts within an assembly.

    JSON:
        ```json
            {
                "xAxis" : [ 1.0, 0.0, 0.0 ],
                "yAxis" : [ 0.0, 0.0, -1.0 ],
                "zAxis" : [ 0.0, 1.0, 0.0 ],
                "origin" : [ 0.0, -0.0505, 0.0 ]
            }
        ```

    Attributes:
        xAxis (list[float]): The x-axis vector of the coordinate system.
        yAxis (list[float]): The y-axis vector of the coordinate system.
        zAxis (list[float]): The z-axis vector of the coordinate system.
        origin (list[float]): The origin point of the coordinate system.

    Examples:
        >>> MatedCS(
        ...     xAxis=[1.0, 0.0, 0.0],
        ...     yAxis=[0.0, 0.0, -1.0],
        ...     zAxis=[0.0, 1.0, 0.0],
        ...     origin=[0.0, -0.0505, 0.0],
        ... )
        MatedCS(
            xAxis=[1.0, 0.0, 0.0],
            yAxis=[0.0, 0.0, -1.0],
            zAxis=[0.0, 1.0, 0.0],
            origin=[0.0, -0.0505, 0.0]
        )
    """

    class Config:
        arbitrary_types_allowed = True

    xAxis: list[float] = Field(..., description="The x-axis vector of the coordinate system.")
    yAxis: list[float] = Field(..., description="The y-axis vector of the coordinate system.")
    zAxis: list[float] = Field(..., description="The z-axis vector of the coordinate system.")
    origin: list[float] = Field(..., description="The origin point of the coordinate system.")

    part_tf: np.matrix = Field(
        None, description="The 4x4 transformation matrix from the part coordinate system to the mate coordinate system."
    )

    @field_validator("xAxis", "yAxis", "zAxis", "origin")
    def check_vectors(cls, v: list[float]) -> list[float]:
        """
        Validates that the vectors have exactly 3 values.

        Args:
            v (list[float]): The vector to validate.

        Returns:
            list[float]: The validated vector.

        Raises:
            ValueError: If the vector does not have exactly 3 values.
        """
        if len(v) != 3:
            raise ValueError("Vectors must have 3 values")

        return v

    @property
    def part_to_mate_tf(self) -> np.matrix:
        """
        Generates a transformation matrix from the part coordinate system to the mate coordinate system.

        Returns:
            np.matrix: The 4x4 transformation matrix.
        """
        if self.part_tf is not None:
            return self.part_tf

        rotation_matrix = np.array([self.xAxis, self.yAxis, self.zAxis]).T
        translation_vector = np.array(self.origin)
        part_to_mate_tf = np.eye(4)
        part_to_mate_tf[:3, :3] = rotation_matrix
        part_to_mate_tf[:3, 3] = translation_vector
        return np.matrix(part_to_mate_tf)

    @classmethod
    def from_tf(cls, tf: np.matrix) -> "MatedCS":
        """
        Creates a MatedCS object from a 4x4 transformation matrix.

        Args:
            tf (np.matrix): The 4x4 transformation matrix.

        Returns:
            MatedCS: The MatedCS object created from the transformation matrix.
        """
        return MatedCS(
            xAxis=tf[:3, 0].flatten().tolist()[0],
            yAxis=tf[:3, 1].flatten().tolist()[0],
            zAxis=tf[:3, 2].flatten().tolist()[0],
            origin=tf[:3, 3].flatten().tolist()[0],
            part_tf=tf,
        )

part_to_mate_tf: np.matrix property

Generates a transformation matrix from the part coordinate system to the mate coordinate system.

Returns:

Type Description
matrix

np.matrix: The 4x4 transformation matrix.

check_vectors(v)

Validates that the vectors have exactly 3 values.

Parameters:

Name Type Description Default
v list[float]

The vector to validate.

required

Returns:

Type Description
list[float]

list[float]: The validated vector.

Raises:

Type Description
ValueError

If the vector does not have exactly 3 values.

Source code in onshape_robotics_toolkit\models\assembly.py
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
@field_validator("xAxis", "yAxis", "zAxis", "origin")
def check_vectors(cls, v: list[float]) -> list[float]:
    """
    Validates that the vectors have exactly 3 values.

    Args:
        v (list[float]): The vector to validate.

    Returns:
        list[float]: The validated vector.

    Raises:
        ValueError: If the vector does not have exactly 3 values.
    """
    if len(v) != 3:
        raise ValueError("Vectors must have 3 values")

    return v

from_tf(tf) classmethod

Creates a MatedCS object from a 4x4 transformation matrix.

Parameters:

Name Type Description Default
tf matrix

The 4x4 transformation matrix.

required

Returns:

Name Type Description
MatedCS MatedCS

The MatedCS object created from the transformation matrix.

Source code in onshape_robotics_toolkit\models\assembly.py
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
@classmethod
def from_tf(cls, tf: np.matrix) -> "MatedCS":
    """
    Creates a MatedCS object from a 4x4 transformation matrix.

    Args:
        tf (np.matrix): The 4x4 transformation matrix.

    Returns:
        MatedCS: The MatedCS object created from the transformation matrix.
    """
    return MatedCS(
        xAxis=tf[:3, 0].flatten().tolist()[0],
        yAxis=tf[:3, 1].flatten().tolist()[0],
        zAxis=tf[:3, 2].flatten().tolist()[0],
        origin=tf[:3, 3].flatten().tolist()[0],
        part_tf=tf,
    )

MatedEntity

Bases: BaseModel

Represents an entity that is mated within an assembly, including its coordinate system.

JSON
    {
        "matedOccurrence": ["MDUJyqGNo7JJll+/h"],
        "matedCS": {
            "xAxis": [1.0, 0.0, 0.0],
            "yAxis": [0.0, 0.0, -1.0],
            "zAxis": [0.0, 1.0, 0.0],
            "origin": [0.0, -0.0505, 0.0]
        }
    }

Attributes:

Name Type Description
matedOccurrence list[str]

A list of identifiers for the occurrences that are mated.

matedCS MatedCS

The coordinate system used for mating the parts.

Examples:

>>> MatedEntity(
...     matedOccurrence=["MDUJyqGNo7JJll+/h"],
...     matedCS=MatedCS(
...         xAxis=[1.0, 0.0, 0.0],
...         yAxis=[0.0, 0.0, -1.0],
...         zAxis=[0.0, 1.0, 0.0],
...         origin=[0.0, -0.0505, 0.0],
...     ),
... )
MatedEntity(
    matedOccurrence=["MDUJyqGNo7JJll+/h"],
    matedCS=MatedCS(
        xAxis=[1.0, 0.0, 0.0],
        yAxis=[0.0, 0.0, -1.0],
        zAxis=[0.0, 1.0, 0.0],
        origin=[0.0, -0.0505, 0.0]
    )
)
Source code in onshape_robotics_toolkit\models\assembly.py
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
class MatedEntity(BaseModel):
    """
    Represents an entity that is mated within an assembly, including its coordinate system.

    JSON:
        ```json
            {
                "matedOccurrence": ["MDUJyqGNo7JJll+/h"],
                "matedCS": {
                    "xAxis": [1.0, 0.0, 0.0],
                    "yAxis": [0.0, 0.0, -1.0],
                    "zAxis": [0.0, 1.0, 0.0],
                    "origin": [0.0, -0.0505, 0.0]
                }
            }
        ```

    Attributes:
        matedOccurrence (list[str]): A list of identifiers for the occurrences that are mated.
        matedCS (MatedCS): The coordinate system used for mating the parts.

    Examples:
        >>> MatedEntity(
        ...     matedOccurrence=["MDUJyqGNo7JJll+/h"],
        ...     matedCS=MatedCS(
        ...         xAxis=[1.0, 0.0, 0.0],
        ...         yAxis=[0.0, 0.0, -1.0],
        ...         zAxis=[0.0, 1.0, 0.0],
        ...         origin=[0.0, -0.0505, 0.0],
        ...     ),
        ... )
        MatedEntity(
            matedOccurrence=["MDUJyqGNo7JJll+/h"],
            matedCS=MatedCS(
                xAxis=[1.0, 0.0, 0.0],
                yAxis=[0.0, 0.0, -1.0],
                zAxis=[0.0, 1.0, 0.0],
                origin=[0.0, -0.0505, 0.0]
            )
        )
    """

    matedOccurrence: list[str] = Field(..., description="A list of identifiers for the occurrences that are mated.")
    matedCS: MatedCS = Field(..., description="The coordinate system used for mating the parts.")

    parentCS: MatedCS = Field(
        None, description="The 4x4 transformation matrix for the mate feature, used for custom transformations."
    )

Occurrence

Bases: BaseModel

Represents an occurrence of a part or sub-assembly within an assembly.

JSON
    {
        "fixed": false,
        "transform": [
            0.8660254037844396, 0.0, 0.5000000000000004, 0.09583333333333346,
            0.0, 1.0, 0.0, -1.53080849893419E-19,
            -0.5000000000000004, 0.0, 0.8660254037844396, 0.16598820239201767,
            0.0, 0.0, 0.0, 1.0
        ],
        "hidden": false,
        "path": ["M0Cyvy+yIq8Rd7En0"]
    }

Attributes:

Name Type Description
fixed bool

Indicates if the occurrence is fixed in space.

transform list[float]

A 4x4 transformation matrix represented as a list of 16 floats.

hidden bool

Indicates if the occurrence is hidden.

path list[str]

A list of strings representing the path to the instance.

Examples:

>>> Occurrence(
...     fixed=False,
...     transform=[
...         0.8660254037844396, 0.0, 0.5000000000000004, 0.09583333333333346,
...         0.0, 1.0, 0.0, -1.53080849893419E-19,
...         -0.5000000000000004, 0.0, 0.8660254037844396, 0.16598820239201767,
...         0.0, 0.0, 0.0, 1.0)
...     ],
...     hidden=False,
...     path=["M0Cyvy+yIq8Rd7En0"]
... )
Occurrence(
    fixed=False,
    transform=[...],
    hidden=False,
    path=["M0Cyvy+yIq8Rd7En0"]
)
Source code in onshape_robotics_toolkit\models\assembly.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
class Occurrence(BaseModel):
    """
    Represents an occurrence of a part or sub-assembly within an assembly.

    JSON:
        ```json
            {
                "fixed": false,
                "transform": [
                    0.8660254037844396, 0.0, 0.5000000000000004, 0.09583333333333346,
                    0.0, 1.0, 0.0, -1.53080849893419E-19,
                    -0.5000000000000004, 0.0, 0.8660254037844396, 0.16598820239201767,
                    0.0, 0.0, 0.0, 1.0
                ],
                "hidden": false,
                "path": ["M0Cyvy+yIq8Rd7En0"]
            }
        ```

    Attributes:
        fixed (bool): Indicates if the occurrence is fixed in space.
        transform (list[float]): A 4x4 transformation matrix represented as a list of 16 floats.
        hidden (bool): Indicates if the occurrence is hidden.
        path (list[str]): A list of strings representing the path to the instance.

    Examples:
        >>> Occurrence(
        ...     fixed=False,
        ...     transform=[
        ...         0.8660254037844396, 0.0, 0.5000000000000004, 0.09583333333333346,
        ...         0.0, 1.0, 0.0, -1.53080849893419E-19,
        ...         -0.5000000000000004, 0.0, 0.8660254037844396, 0.16598820239201767,
        ...         0.0, 0.0, 0.0, 1.0)
        ...     ],
        ...     hidden=False,
        ...     path=["M0Cyvy+yIq8Rd7En0"]
        ... )
        Occurrence(
            fixed=False,
            transform=[...],
            hidden=False,
            path=["M0Cyvy+yIq8Rd7En0"]
        )
    """

    fixed: bool = Field(..., description="Indicates if the occurrence is fixed in space.")
    transform: list[float] = Field(..., description="A 4x4 transformation matrix represented as a list of 16 floats.")
    hidden: bool = Field(..., description="Indicates if the occurrence is hidden.")
    path: list[str] = Field(..., description="A list of strings representing the path to the instance.")

    @field_validator("transform")
    def check_transform(cls, v: list[float]) -> list[float]:
        """
        Validates that the transform list has exactly 16 values.

        Args:
            v (list[float]): The transform list to validate.

        Returns:
            list[float]: The validated transform list.

        Raises:
            ValueError: If the transform list does not contain exactly 16 values.
        """
        if len(v) != 16:
            raise ValueError("Transform must have 16 values")

        return v

check_transform(v)

Validates that the transform list has exactly 16 values.

Parameters:

Name Type Description Default
v list[float]

The transform list to validate.

required

Returns:

Type Description
list[float]

list[float]: The validated transform list.

Raises:

Type Description
ValueError

If the transform list does not contain exactly 16 values.

Source code in onshape_robotics_toolkit\models\assembly.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@field_validator("transform")
def check_transform(cls, v: list[float]) -> list[float]:
    """
    Validates that the transform list has exactly 16 values.

    Args:
        v (list[float]): The transform list to validate.

    Returns:
        list[float]: The validated transform list.

    Raises:
        ValueError: If the transform list does not contain exactly 16 values.
    """
    if len(v) != 16:
        raise ValueError("Transform must have 16 values")

    return v

Part

Bases: IDBase

Represents a part within an assembly, including its properties and configuration.

JSON
    {
        "isStandardContent": false,
        "partId": "RDBD",
        "bodyType": "solid",
        "fullConfiguration": "default",
        "configuration": "default",
        "documentId": "a1c1addf75444f54b504f25c",
        "elementId": "0b0c209535554345432581fe",
        "documentMicroversion": "349f6413cafefe8fb4ab3b07"
    }

Attributes:

Name Type Description
isStandardContent bool

Indicates if the part is standard content.

partId str

The unique identifier of the part.

bodyType str

The type of the body (e.g., solid, surface).

Custom Attributes

MassProperty (Union[MassProperties, None]): The mass properties of the part, if available.

Examples:

>>> Part(
...     isStandardContent=False,
...     partId="RDBD",
...     bodyType="solid",
... )
Part(
    isStandardContent=False,
    partId="RDBD",
    bodyType="solid",
    MassProperty=None
)
Source code in onshape_robotics_toolkit\models\assembly.py
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
class Part(IDBase):
    """
    Represents a part within an assembly, including its properties and configuration.

    JSON:
        ```json
            {
                "isStandardContent": false,
                "partId": "RDBD",
                "bodyType": "solid",
                "fullConfiguration": "default",
                "configuration": "default",
                "documentId": "a1c1addf75444f54b504f25c",
                "elementId": "0b0c209535554345432581fe",
                "documentMicroversion": "349f6413cafefe8fb4ab3b07"
            }
        ```

    Attributes:
        isStandardContent (bool): Indicates if the part is standard content.
        partId (str): The unique identifier of the part.
        bodyType (str): The type of the body (e.g., solid, surface).

    Custom Attributes:
        MassProperty (Union[MassProperties, None]): The mass properties of the part, if available.

    Examples:
        >>> Part(
        ...     isStandardContent=False,
        ...     partId="RDBD",
        ...     bodyType="solid",
        ... )
        Part(
            isStandardContent=False,
            partId="RDBD",
            bodyType="solid",
            MassProperty=None
        )

    """

    isStandardContent: bool = Field(..., description="Indicates if the part is standard content.")
    partId: str = Field(..., description="The unique identifier of the part.")
    bodyType: str = Field(..., description="The type of the body (e.g., solid, surface).")
    mateConnectors: list[PartMateConnector] = Field(None, description="The mate connectors that belong to the part.")
    documentVersion: str = Field(None, description="The version of the document.")
    MassProperty: Union[MassProperties, None] = Field(
        None, description="The mass properties of the part, this is a retrieved via a separate API call."
    )

    isRigidAssembly: bool = Field(
        False, description="Indicates if the part is a rigid assembly, i.e., a sub-assembly with no degrees of freedom."
    )
    rigidAssemblyToPartTF: Union[dict[str, "MatedCS"], None] = Field(
        None, description="The transformation matrix from the rigid assembly to the part coordinate system."
    )
    rigidAssemblyWorkspaceId: Union[str, None] = Field(
        None, description="The workspace ID of the rigid assembly, if it is a sub-assembly."
    )

    @property
    def uid(self) -> str:
        """
        Generates a unique identifier for the part.

        Returns:
            str: The unique identifier generated from documentId, documentMicroversion,
                elementId, partId, and fullConfiguration.
        """
        return generate_uid([
            self.documentId,
            self.documentMicroversion,
            self.elementId,
            self.partId,
            self.fullConfiguration,
        ])

uid: str property

Generates a unique identifier for the part.

Returns:

Name Type Description
str str

The unique identifier generated from documentId, documentMicroversion, elementId, partId, and fullConfiguration.

PartInstance

Bases: IDBase

Represents an instance of a part within an assembly.

JSON
    {
        "isStandardContent": false,
        "type": "Part",
        "id": "M0Cyvy+yIq8Rd7En0",
        "name": "Part 1 <2>",
        "suppressed": false,
        "partId": "JHD",
        "fullConfiguration": "default",
        "configuration": "default",
        "documentId": "a1c1addf75444f54b504f25c",
        "elementId": "0b0c209535554345432581fe",
        "documentMicroversion": "349f6413cafefe8fb4ab3b07"
    }

Attributes:

Name Type Description
isStandardContent bool

Indicates if the part is standard content.

type InstanceType

The type of the instance, must be 'Part'.

id str

The unique identifier for the part instance.

name str

The name of the part instance.

suppressed bool

Indicates if the part instance is suppressed.

partId str

The identifier for the part.

Examples:

>>> PartInstance(
...     isStandardContent=False,
...     type=InstanceType.PART,
...     id="M0Cyvy+yIq8Rd7En0",
...     name="Part 1 <2>",
...     suppressed=False,
...     partId="JHD",
... )
PartInstance(
    isStandardContent=False,
    type=InstanceType.PART,
    id="M0Cyvy+yIq8Rd7En0",
    name="Part 1 <2>",
    suppressed=False,
    partId="JHD",
)
Source code in onshape_robotics_toolkit\models\assembly.py
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
class PartInstance(IDBase):
    """
    Represents an instance of a part within an assembly.

    JSON:
        ```json
            {
                "isStandardContent": false,
                "type": "Part",
                "id": "M0Cyvy+yIq8Rd7En0",
                "name": "Part 1 <2>",
                "suppressed": false,
                "partId": "JHD",
                "fullConfiguration": "default",
                "configuration": "default",
                "documentId": "a1c1addf75444f54b504f25c",
                "elementId": "0b0c209535554345432581fe",
                "documentMicroversion": "349f6413cafefe8fb4ab3b07"
            }
        ```

    Attributes:
        isStandardContent (bool): Indicates if the part is standard content.
        type (InstanceType): The type of the instance, must be 'Part'.
        id (str): The unique identifier for the part instance.
        name (str): The name of the part instance.
        suppressed (bool): Indicates if the part instance is suppressed.
        partId (str): The identifier for the part.

    Examples:
        >>> PartInstance(
        ...     isStandardContent=False,
        ...     type=InstanceType.PART,
        ...     id="M0Cyvy+yIq8Rd7En0",
        ...     name="Part 1 <2>",
        ...     suppressed=False,
        ...     partId="JHD",
        ... )
        PartInstance(
            isStandardContent=False,
            type=InstanceType.PART,
            id="M0Cyvy+yIq8Rd7En0",
            name="Part 1 <2>",
            suppressed=False,
            partId="JHD",
        )
    """

    isStandardContent: bool = Field(..., description="Indicates if the part is standard content.")
    type: InstanceType = Field(..., description="The type of the instance, must be 'Part'.")
    documentVersion: str = Field(None, description="The version of the document.")
    id: str = Field(..., description="The unique identifier for the part instance.")
    name: str = Field(..., description="The name of the part instance.")
    suppressed: bool = Field(..., description="Indicates if the part instance is suppressed.")
    partId: str = Field(..., description="The identifier for the part.")

    @field_validator("type")
    def check_type(cls, v: InstanceType) -> InstanceType:
        """
        Validates that the type is 'Part'.

        Args:
            v (InstanceType): The type to validate.

        Returns:
            InstanceType: The validated type.
        """
        if v != InstanceType.PART:
            raise ValueError("Type must be Part")

        return v

    @property
    def uid(self) -> str:
        """
        Generates a unique identifier for the part instance based on its attributes.

        Returns:
            str: The unique identifier for the part instance.
        """
        return generate_uid([
            self.documentId,
            self.documentMicroversion,
            self.elementId,
            self.partId,
            self.fullConfiguration,
        ])

uid: str property

Generates a unique identifier for the part instance based on its attributes.

Returns:

Name Type Description
str str

The unique identifier for the part instance.

check_type(v)

Validates that the type is 'Part'.

Parameters:

Name Type Description Default
v InstanceType

The type to validate.

required

Returns:

Name Type Description
InstanceType InstanceType

The validated type.

Source code in onshape_robotics_toolkit\models\assembly.py
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
@field_validator("type")
def check_type(cls, v: InstanceType) -> InstanceType:
    """
    Validates that the type is 'Part'.

    Args:
        v (InstanceType): The type to validate.

    Returns:
        InstanceType: The validated type.
    """
    if v != InstanceType.PART:
        raise ValueError("Type must be Part")

    return v

PartMateConnector

Bases: BaseModel

Represents a mate connector within a part.

JSON
    {
    "mateConnectorCS" : {
        "xAxis" : [ 1.0, 0.0, 0.0 ],
        "yAxis" : [ 0.0, 1.0, 0.0 ],
        "zAxis" : [ 0.0, 0.0, 1.0 ],
        "origin" : [ 0.0, 0.0, 0.024999999999999984 ]
    },
    "featureId" : "FuB5m1oLMD3WyJ1_1"
    }

Attributes:

Name Type Description
mateConnectorCS MatedCS

The coordinate system used for the mate connector.

featureId str

The unique identifier of the mate connector feature.

Examples:

>>> PartMateConnector(
...     mateConnectorCS=MatedCS(
...         xAxis=[1.0, 0.0, 0.0],
...         yAxis=[0.0, 1.0, 0.0],
...         zAxis=[0.0, 0.0, 1.0],
...         origin=[0.0, 0.0, 0.024999999999999984],
...     ),
...     featureId="FuB5m1oLMD3WyJ1_1",
... )
PartMateConnector(
    mateConnectorCS=MatedCS(
        xAxis=[1.0, 0.0, 0.0],
        yAxis=[0.0, 1.0, 0.0],
        zAxis=[0.0, 0.0, 1.0],
        origin=[0.0, 0.0, 0.024999999999999984]
    ),
    featureId="FuB5m1oLMD3WyJ1_1"
)
Source code in onshape_robotics_toolkit\models\assembly.py
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
class PartMateConnector(BaseModel):
    """
    Represents a mate connector within a part.

    JSON:
        ```json
            {
            "mateConnectorCS" : {
                "xAxis" : [ 1.0, 0.0, 0.0 ],
                "yAxis" : [ 0.0, 1.0, 0.0 ],
                "zAxis" : [ 0.0, 0.0, 1.0 ],
                "origin" : [ 0.0, 0.0, 0.024999999999999984 ]
            },
            "featureId" : "FuB5m1oLMD3WyJ1_1"
            }
        ```

    Attributes:
        mateConnectorCS (MatedCS): The coordinate system used for the mate connector.
        featureId (str): The unique identifier of the mate connector feature.

    Examples:
        >>> PartMateConnector(
        ...     mateConnectorCS=MatedCS(
        ...         xAxis=[1.0, 0.0, 0.0],
        ...         yAxis=[0.0, 1.0, 0.0],
        ...         zAxis=[0.0, 0.0, 1.0],
        ...         origin=[0.0, 0.0, 0.024999999999999984],
        ...     ),
        ...     featureId="FuB5m1oLMD3WyJ1_1",
        ... )
        PartMateConnector(
            mateConnectorCS=MatedCS(
                xAxis=[1.0, 0.0, 0.0],
                yAxis=[0.0, 1.0, 0.0],
                zAxis=[0.0, 0.0, 1.0],
                origin=[0.0, 0.0, 0.024999999999999984]
            ),
            featureId="FuB5m1oLMD3WyJ1_1"
        )
    """

    mateConnectorCS: "MatedCS" = Field(..., description="The coordinate system used for the mate connector.")
    featureId: str = Field(..., description="The unique identifier of the mate connector feature.")

Pattern

Bases: BaseModel

Represents a pattern feature within an assembly, defining repeated instances of parts or sub-assemblies.

Source code in onshape_robotics_toolkit\models\assembly.py
1105
1106
1107
1108
1109
1110
1111
class Pattern(BaseModel):
    """
    Represents a pattern feature within an assembly, defining repeated instances of parts or sub-assemblies.
    """

    # TODO: Implement Pattern model
    pass

RelationType

Bases: str, Enum

Enumerates the type of mate relation between two parts or assemblies, e.g. LINEAR, GEAR, SCREW, etc.

Attributes:

Name Type Description
LINEAR str

Represents a linear relation.

GEAR str

Represents a gear relation.

SCREW str

Represents a screw relation.

RACK_AND_PINION str

Represents a rack and pinion relation.

Examples:

>>> RelationType.LINEAR
'LINEAR'
>>> RelationType.GEAR
'GEAR'
Source code in onshape_robotics_toolkit\models\assembly.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
class RelationType(str, Enum):
    """
    Enumerates the type of mate relation between two parts or assemblies, e.g. LINEAR, GEAR, SCREW, etc.

    Attributes:
        LINEAR (str): Represents a linear relation.
        GEAR (str): Represents a gear relation.
        SCREW (str): Represents a screw relation.
        RACK_AND_PINION (str): Represents a rack and pinion relation.

    Examples:
        >>> RelationType.LINEAR
        'LINEAR'
        >>> RelationType.GEAR
        'GEAR'
    """

    LINEAR = "LINEAR"
    GEAR = "GEAR"
    SCREW = "SCREW"
    RACK_AND_PINION = "RACK_AND_PINION"

RootAssembly

Bases: SubAssembly

Represents the root assembly, which is the top-level assembly containing all parts and sub-assemblies.

JSON
    {
        "instances": [],
        "patterns": [],
        "features": [],
        "occurrences": [],
        "fullConfiguration": "default",
        "configuration": "default",
        "documentId": "a1c1addf75444f54b504f25c",
        "elementId": "0b0c209535554345432581fe",
        "documentMicroversion": "349f6413cafefe8fb4ab3b07"
    }

Attributes:

Name Type Description
instances list[Union[PartInstance, AssemblyInstance]]

A list of part and assembly instances in the root assembly.

patterns list[Pattern]

A list of patterns in the root assembly.

features list[AssemblyFeature]

A list of features in the root assembly.

occurrences list[Occurrence]

A list of occurrences in the root assembly.

fullConfiguration str

The full configuration of the root assembly.

configuration str

The configuration of the root assembly.

documentId str

The unique identifier of the document containing the root assembly.

elementId str

The unique identifier of the element containing the root assembly.

documentMicroversion str

The microversion of the document containing the root assembly.

Examples:

>>> RootAssembly(
...     instances=[...],
...     patterns=[...],
...     features=[...],
...     occurrences=[...],
...     fullConfiguration="default",
...     configuration="default",
...     documentId="a1c1addf75444f54b504f25c",
...     elementId="0b0c209535554345432581fe",
...     documentMicroversion="349f6413cafefe8fb4ab3b07",
... )
RootAssembly(
    instances=[...],
    patterns=[...],
    features=[...],
    occurrences=[...],
    fullConfiguration="default",
    configuration="default",
    documentId="a1c1addf75444f54b504f25c",
    elementId="0b0c209535554345432581fe",
    documentMicroversion="349f6413cafefe8fb4ab3b07"
)
Source code in onshape_robotics_toolkit\models\assembly.py
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
class RootAssembly(SubAssembly):
    """
    Represents the root assembly, which is the top-level assembly containing all parts and sub-assemblies.

    JSON:
        ```json
            {
                "instances": [],
                "patterns": [],
                "features": [],
                "occurrences": [],
                "fullConfiguration": "default",
                "configuration": "default",
                "documentId": "a1c1addf75444f54b504f25c",
                "elementId": "0b0c209535554345432581fe",
                "documentMicroversion": "349f6413cafefe8fb4ab3b07"
            }
        ```

    Attributes:
        instances (list[Union[PartInstance, AssemblyInstance]]):
            A list of part and assembly instances in the root assembly.
        patterns (list[Pattern]): A list of patterns in the root assembly.
        features (list[AssemblyFeature]): A list of features in the root assembly.
        occurrences (list[Occurrence]): A list of occurrences in the root assembly.
        fullConfiguration (str): The full configuration of the root assembly.
        configuration (str): The configuration of the root assembly.
        documentId (str): The unique identifier of the document containing the root assembly.
        elementId (str): The unique identifier of the element containing the root assembly.
        documentMicroversion (str): The microversion of the document containing the root assembly.

    Examples:
        >>> RootAssembly(
        ...     instances=[...],
        ...     patterns=[...],
        ...     features=[...],
        ...     occurrences=[...],
        ...     fullConfiguration="default",
        ...     configuration="default",
        ...     documentId="a1c1addf75444f54b504f25c",
        ...     elementId="0b0c209535554345432581fe",
        ...     documentMicroversion="349f6413cafefe8fb4ab3b07",
        ... )
        RootAssembly(
            instances=[...],
            patterns=[...],
            features=[...],
            occurrences=[...],
            fullConfiguration="default",
            configuration="default",
            documentId="a1c1addf75444f54b504f25c",
            elementId="0b0c209535554345432581fe",
            documentMicroversion="349f6413cafefe8fb4ab3b07"
        )
    """

    occurrences: list[Occurrence] = Field(..., description="A list of occurrences in the root assembly.")

    documentMetaData: Union[DocumentMetaData, None] = Field(
        None, description="The document associated with the assembly."
    )

SubAssembly

Bases: IDBase

Represents a sub-assembly within a root assembly.

JSON
    {
        "instances": [],
        "patterns": [],
        "features": [],
        "fullConfiguration": "default",
        "configuration": "default",
        "documentId": "a1c1addf75444f54b504f25c",
        "elementId": "0b0c209535554345432581fe",
        "documentMicroversion": "349f6413cafefe8fb4ab3b07"
    }

Attributes:

Name Type Description
instances list[Union[PartInstance, AssemblyInstance]]

A list of part and assembly instances in the sub-assembly.

patterns list[Pattern]

A list of patterns in the sub-assembly.

features list[AssemblyFeature]

A list of features in the sub-assembly

fullConfiguration str

The full configuration of the sub-assembly.

configuration str

The configuration of the sub-assembly.

documentId str

The unique identifier of the document containing the sub-assembly.

elementId str

The unique identifier of the element containing the sub-assembly.

documentMicroversion str

The microversion of the document containing the sub-assembly.

Properties

uid (str): A unique identifier for the sub-assembly based on documentId, documentMicroversion, elementId, and fullConfiguration.

Examples:

>>> SubAssembly(
...     instances=[...],
...     patterns=[...],
...     features=[...],
...     fullConfiguration="default",
...     configuration="default",
...     documentId="a1c1addf75444f54b504f25c",
...     elementId="0b0c209535554345432581fe",
...     documentMicroversion="349f6413cafefe8fb4ab3b07",
... )
SubAssembly(
    instances=[...],
    patterns=[...],
    features=[...],
    fullConfiguration="default",
    configuration="default",
    documentId="a1c1addf75444f54b504f25c",
    elementId="0b0c209535554345432581fe",
    documentMicroversion="349f6413cafefe8fb4ab3b07"
)
Source code in onshape_robotics_toolkit\models\assembly.py
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
class SubAssembly(IDBase):
    """
    Represents a sub-assembly within a root assembly.

    JSON:
        ```json
            {
                "instances": [],
                "patterns": [],
                "features": [],
                "fullConfiguration": "default",
                "configuration": "default",
                "documentId": "a1c1addf75444f54b504f25c",
                "elementId": "0b0c209535554345432581fe",
                "documentMicroversion": "349f6413cafefe8fb4ab3b07"
            }
        ```

    Attributes:
        instances (list[Union[PartInstance, AssemblyInstance]]):
            A list of part and assembly instances in the sub-assembly.
        patterns (list[Pattern]): A list of patterns in the sub-assembly.
        features (list[AssemblyFeature]): A list of features in the sub-assembly
        fullConfiguration (str): The full configuration of the sub-assembly.
        configuration (str): The configuration of the sub-assembly.
        documentId (str): The unique identifier of the document containing the sub-assembly.
        elementId (str): The unique identifier of the element containing the sub-assembly.
        documentMicroversion (str): The microversion of the document containing the sub-assembly.

    Properties:
        uid (str): A unique identifier for the sub-assembly based on documentId, documentMicroversion, elementId, and
            fullConfiguration.

    Examples:
        >>> SubAssembly(
        ...     instances=[...],
        ...     patterns=[...],
        ...     features=[...],
        ...     fullConfiguration="default",
        ...     configuration="default",
        ...     documentId="a1c1addf75444f54b504f25c",
        ...     elementId="0b0c209535554345432581fe",
        ...     documentMicroversion="349f6413cafefe8fb4ab3b07",
        ... )
        SubAssembly(
            instances=[...],
            patterns=[...],
            features=[...],
            fullConfiguration="default",
            configuration="default",
            documentId="a1c1addf75444f54b504f25c",
            elementId="0b0c209535554345432581fe",
            documentMicroversion="349f6413cafefe8fb4ab3b07"
        )

    """

    instances: list[Union[PartInstance, AssemblyInstance]] = Field(
        ..., description="A list of part and assembly instances in the sub-assembly."
    )
    patterns: list[Pattern] = Field(..., description="A list of patterns in the sub-assembly.")
    features: list[AssemblyFeature] = Field(..., description="A list of features in the sub-assembly")

    MassProperty: Union[MassProperties, None] = Field(
        None, description="The mass properties of the sub-assembly, this is a retrieved via a separate API call."
    )

    @property
    def uid(self) -> str:
        """
        Generates a unique identifier for the sub-assembly with documentId, documentMicroversion, elementId, and
        fullConfiguration.

        Returns:
            str: The unique identifier for the sub-assembly.
        """
        return generate_uid([self.documentId, self.documentMicroversion, self.elementId, self.fullConfiguration])

uid: str property

Generates a unique identifier for the sub-assembly with documentId, documentMicroversion, elementId, and fullConfiguration.

Returns:

Name Type Description
str str

The unique identifier for the sub-assembly.