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.
Anyone know how to get part studio configuration variables via the API?
darren_lynch
Member Posts: 3 ✭✭
I was expecting something like this to work:
def from_did_wid_eid(did, wid, eid):
"""
Retrieve valid configuration variables for a Part Studio in Onshape.
Parameters:
- client: An instance of the Onshape client
- did: Document ID
- wid: Workspace ID
- eid: Element ID
Returns:
- A list of configuration variables with their details
"""
client = _sop.get.api_client.from_dot_env()
config_info = client.part_studios_api.get_part_studio_configuration(
did=did,
wvm="w",
wvmid=wid,
eid=eid,
)
return config_info #Expected something, got None
Tagged:
0
Best Answer
-
Caden_Armstrong
Member Posts: 336 PRO
In the documentation its this endpoint:
https://cad.onshape.com/glassworks/explorer/#/Element/getConfigurationI don't use the python client, but its probably under some kind of elements_api instead of part_studios.
www.smartbenchsoftware.com --- fs.place --- Renaissance
Custom FeatureScript and Onshape Integrated Applications1
Answers
In the documentation its this endpoint:
https://cad.onshape.com/glassworks/explorer/#/Element/getConfiguration
I don't use the python client, but its probably under some kind of elements_api instead of part_studios.
Custom FeatureScript and Onshape Integrated Applications
Thanks @Caden_Armstrong that helped.
For anyone doing this in the future, not sure the python sdk response is working correctly, if you run this:
import json import simscale_onshape_playground as _sop def test_sdk_vs_raw_response(): did = "did" wid = "wid" eid = "eid" client = _sop.get.api_client.from_dot_env() print("=== SDK Method Response ===") config_info = client.elements_api.get_configuration( did=did, wvm="w", wvmid=wid, eid=eid, ) print("Object type:", type(config_info)) print("vars(config_info):", vars(config_info)) try: print("to_dict():", config_info.to_dict()) except Exception as e: print("to_dict() failed:", e) print("\n=== Raw API Response ===") # Patch broken endpoint to allow call_with_http_info to work client.elements_api.get_configuration.settings["servers"] = ["https://cad.onshape.com"] raw_response = client.elements_api.get_configuration( did=did, wvm="w", wvmid=wid, eid=eid, _preload_content=False, _return_http_data_only=False ) raw_json = json.loads(raw_response[0].read().decode()) print(json.dumps(raw_json, indent=2)) if __name__ == "__main__": test_sdk_vs_raw_response()You get an empty object, but if you include _preload_content=False, _return_http_data_only=False you get something, but then you need to process it.