Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Python assembly API -- Creating a mate connector on existing geometry
francesco_nori
Member Posts: 4 ✭
I am using the python client API to create a mate connector on an existing assembly. The idea is to create a mate connector on an existing geometry. Using the API explorer I could find the body content for a message for the "add feature" function (adding a mate connector on the centroid of the geometry "JKW" belonging to "M420TZZdOPK8489yw" ):
{ "feature" : { "type" : 66, "typeName" : "BTMMateConnector", "message" : { "version" : 4, "featureType" : "mateConnector", "name" : "Mate connector 1", "parameters" : [ { "type" : 67, "typeName" : "BTMParameterQueryWithOccurrenceList", "message" : { "queries" : [ { "type" : 1083, "typeName" : "BTMInferenceQueryWithOccurrence", "message" : {"inferenceType" : "CENTROID", "geometryIds" : [ "JKW" ], "path" : [ "M420TZZdOPK8489yw" ]} } ], "parameterId" : "originQuery" } } ] } } }
I am trying to replicate the same behaviour from the python client API. The code looks like:
centroid_query = onshape_client.oas.BTMInferenceQueryWithOccurrence1083( bt_type="BTMInferenceQueryWithOccurrence", inference_type="CENTROID", deterministic_ids=["JKW"], path=["M420TZZdOPK8489yw"]) centroid_parameter = onshape_client.oas.BTMParameterQueryWithOccurrenceList67( bt_type="BTMParameterQueryWithOccurrenceList", queries=[centroid_query], parameter_id="originQuery") mate_definition = onshape_client.oas.BTMMateConnector66( bt_type="BTMMateConnector", feature_type="mateConnector", name="Mate connector Python", parameters=[centroid_parameter], version=4)
However, the resulting body message differs from the one above and seems to be missing some information:
Francesco
{ "btType":"BTMMateConnector", "featureType":"mateConnector", "name":"Mate connector Python", "parameters":[ { "btType":"BTMParameterQueryWithOccurrenceList", "queries":[ { "btType":"BTMInferenceQueryWithOccurrence", "inferenceType":"CENTROID", "deterministicIds":[ "JKW" ], "path":[ "M420TZZdOPK8489yw" ] } ], "parameterId":"originQuery" } ], "version":4 }What am I doing wrong?
Francesco
0