Exemplo n.º 1
0
def test_create_surface(client, part_studio):
    test_insert_line_sketch(client, part_studio)
    tool_body_type = BTMParameterEnum145(
        value="SURFACE", enum_name="ToolBodyType", parameter_id="bodyType"
    )
    operation_type = BTMParameterEnum145(
        value="NEW",
        enum_name="NewSurfaceOperationType",
        parameter_id="surfaceOperationType",
    )
    line_query = BTMParameterQueryList148(
        parameter_id="surfaceEntities",
        queries=[BTMIndividualQuery138(deterministic_ids=["JFB"])],
    )
    length = BTMParameterQuantity147(expression="3.03*in", parameter_id="depth")
    extrude_feature = BTMFeature134(
        bt_type="BTMFeature-134",
        name="My extrude",
        feature_type="extrude",
        parameters=[tool_body_type, operation_type, line_query, length],
    )
    feature_definition = BTFeatureDefinitionCall1406(feature=extrude_feature)
    client.part_studios_api.add_part_studio_feature(
        did=part_studio.did,
        wvm=part_studio.wvm,
        wvmid=part_studio.wvmid,
        eid=part_studio.eid,
        bt_feature_definition_call_1406=feature_definition,
        _preload_content=False,
    )
Exemplo n.º 2
0
element = OnshapeElement(
	'https://rogers.onshape.com/documents/b7c65d78bde731408815188e/w/09daa8ec5418b4d1e583d4b3/e/96d39b57bfcc8cca0d96c2b5'
)

key = ""
secret = ""

with open('../scripts/api-key', "r") as f: 
	key = f.readline().rstrip()
	secret = f.readline().rstrip()

base_url = 'https://rogers.onshape.com'

client = Client(configuration={"base_url": base_url, "access_key": key, "secret_key": secret})

Square0 = BTMSketch151(entities=[BTMSketchCurveSegment155(start_point="LINE1.start", end_point_id="LINE1.end", start_param=0.0, end_param=1.0, geometry=BTCurveGeometryLine117(pnt_x=0.0, pnt_y=0.0, dir_x=0.0, dir_y=0.0254, bt_type="BTCurveGeometryLine-117"), entity_id="LINE1", bt_type="BTMSketchCurveSegment-155"),BTMSketchCurveSegment155(start_point="LINE2.start", end_point_id="LINE2.end", start_param=0.0, end_param=1.0, geometry=BTCurveGeometryLine117(pnt_x=0.0, pnt_y=0.0254, dir_x=0.0254, dir_y=0.0, bt_type="BTCurveGeometryLine-117"), entity_id="LINE2", bt_type="BTMSketchCurveSegment-155"),BTMSketchCurveSegment155(start_point="LINE3.start", end_point_id="LINE3.end", start_param=0.0, end_param=1.0, geometry=BTCurveGeometryLine117(pnt_x=0.0254, pnt_y=0.0254, dir_x=0.0, dir_y=-0.0254, bt_type="BTCurveGeometryLine-117"), entity_id="LINE3", bt_type="BTMSketchCurveSegment-155"),BTMSketchCurveSegment155(start_point="LINE4.start", end_point_id="LINE4.end", start_param=0.0, end_param=1.0, geometry=BTCurveGeometryLine117(pnt_x=0.0254, pnt_y=0.0, dir_x=-0.0254, dir_y=0.0, bt_type="BTCurveGeometryLine-117"), entity_id="LINE4", bt_type="BTMSketchCurveSegment-155"),], name="Square", parameters=[BTMParameterQueryList148(parameter_id="sketchPlane", queries=[BTMIndividualQuery138(deterministic_ids=['JDC'])]),BTMParameterQuantity147(expression="1*in", parameter_id="length", bt_type="BTMParameterQuantity-147"),], constraints=[BTMSketchConstraint2(constraint_type="COINCIDENT",parameters=[BTMParameterString149(value="point1", parameter_id="localFirst", bt_type="BTMParameterString-149"),BTMParameterString149(value="'LINE1.start", parameter_id="localSecond", bt_type="BTMParameterString-149"),],entity_id="constrainId",bt_type="BTMSketchConstraint-2"),BTMSketchConstraint2(constraint_type="LENGTH",parameters=[BTMParameterString149(value="point1", parameter_id="localFirst", bt_type="BTMParameterString-149"),BTMParameterString149(value="'LINE1.start", parameter_id="localSecond", bt_type="BTMParameterString-149"),BTMParameterQuantity147(expression="1*in", parameter_id="length", bt_type="BTMParameterQuantity-147"),],entity_id="constrainId",bt_type="BTMSketchConstraint-2"),], bt_type="BTMSketch-151")

Square_Extrude1 = BTMFeature134(bt_type="BTMParameterQuantity-147", name="Square Extrude", feature_type="extrude", parameters=[BTMParameterEnum145(enum_name="ToolBodyType",value="SURFACE",parameter_id="bodyType"),BTMParameterEnum145(enum_name="OperationDomain",value="MODEL",parameter_id="domain"),BTMParameterEnum145(enum_name="SecondDirectionBoundingType",value="BLIND",parameter_id="secondDirectionBound"),BTMParameterEnum145(enum_name="BoundingType",value="BLIND",parameter_id="endBound"),BTMParameterQueryList148(parameter_id="endBoundEntityFace", queries=[]),BTMParameterQueryList148(parameter_id="endBoundEntityBody", queries=[]),BTMParameterQueryList148(parameter_id="endBoundEntityVertex", queries=[]),BTMParameterEnum145(enum_name="NewBodyOperationType",value="NEW",parameter_id="operationType"),BTMParameterEnum145(enum_name="NewSurfaceOperationType",value="NEW",parameter_id="surfaceOperationType"),BTMParameterEnum145(enum_name="FlatOperationType",value="REMOVE",parameter_id="flatOperationType"),BTMParameterQueryList148(parameter_id="surfaceEntities", queries=[BTMIndividualQuery138(deterministic_ids=['JGC'])]),BTMParameterQuantity147(expression="1*in",parameter_id="depth"),])

Circle_On_a_Face2 = BTMSketch151(entities=[BTMSketchCurve4(center_id="Circle.center", entity_id="Circle", geometry=BTCurveGeometryCircle115(radius=0.00635, xcenter=0.0127, ycenter=0.0127, xdir=0.0127, ydir=0.0, clockwise=False)),], name="Circle On a Face", parameters=[BTMParameterQueryList148(parameter_id="sketchPlane", queries=[BTMIndividualQuery138(deterministic_ids=['JGC'])]),], constraints=[], bt_type="BTMSketch-151")

Extrude_Remove_Circle3 = BTMFeature134(bt_type="BTMParameterQuantity-147", name="Extrude Remove Circle", feature_type="extrude", parameters=[BTMParameterEnum145(enum_name="OperationDomain",value="MODEL",parameter_id="domain"),BTMParameterEnum145(enum_name="ToolBodyType",value="SOLID",parameter_id="bodyType"),BTMParameterEnum145(enum_name="NewBodyOperationType",value="REMOVE",parameter_id="operationType"),BTMParameterEnum145(enum_name="BoundingType",value="BLIND",parameter_id="endBound"),BTMParameterQueryList148(parameter_id="booleanScope", queries=[BTMIndividualQuery138(deterministic_ids=['JHD'])]),BTMParameterQueryList148(parameter_id="booleanSurfaceScope", queries=[]),BTMParameterQuantity147(expression="1 in",parameter_id="offsetDistance"),BTMParameterQuantity147(expression="1 in",parameter_id="secondDirectionDepth"),BTMParameterQueryList148(parameter_id="surfaceEntities", queries=[]),BTMParameterEnum145(enum_name="NewSurfaceOperationType",value="NEW",parameter_id="surfaceOperationType"),BTMParameterEnum145(enum_name="FlatOperationType",value="REMOVE",parameter_id="flatOperationType"),BTMParameterQueryList148(parameter_id="entities", queries=[BTMIndividualQuery138(deterministic_ids=['JJC'])]),BTMParameterQuantity147(expression="1 in",parameter_id="depth"),])

def funcTester(func_string, part_studio, client):
	feature_definition = BTFeatureDefinitionCall1406(feature=func_string)
	client.part_studios_api.add_part_studio_feature(
	    did=part_studio.did,
	    wvm=part_studio.wvm,
	    wvmid=part_studio.wvmid,
	    eid=part_studio.eid,
	    bt_feature_definition_call_1406=feature_definition,
Exemplo n.º 3
0
def create_square(client, part_studio):
    FEATURE_NAME = "Square"
    PLANE_ID = "JDC"  # The plane deterministic ID for the sketch
    plane_query = BTMParameterQueryList148(
        parameter_id="sketchPlane",
        queries=[BTMIndividualQuery138(deterministic_ids=[PLANE_ID])],
    )
    LINE_ID = "myLine"
    START = "start"
    END = "end"
    POINT_ID = "myPoint"

    point_string_param = BTMParameterString149(
        value='point1', parameter_id="localFirst", bt_type="BTMParameterString-149"
    )
    point_string_param2 = BTMParameterString149(
        value='point2', parameter_id="localFirst", bt_type="BTMParameterString-149"
    )
    point_string_param3 = BTMParameterString149(
        value='point3', parameter_id="localFirst", bt_type="BTMParameterString-149"
    )
    point_string_param4 = BTMParameterString149(
        value='point4', parameter_id="localFirst", bt_type="BTMParameterString-149"
    )
    line_end_string_param = BTMParameterString149(
        value=f"LINE1.start",
        parameter_id="localSecond",
        bt_type="BTMParameterString-149",
    )
    line_end_string_param2 = BTMParameterString149(
        value=f"LINE2.start",
        parameter_id="localSecond",
        bt_type="BTMParameterString-149",
    )
    line_end_string_param3 = BTMParameterString149(
        value=f"LINE3.start",
        parameter_id="localSecond",
        bt_type="BTMParameterString-149",
    )
    line_end_string_param4 = BTMParameterString149(
        value=f"LINE4.start",
        parameter_id="localSecond",
        bt_type="BTMParameterString-149",
    )
    length = BTMParameterQuantity147(expression="1*in", parameter_id="length")
    coincident_constraint1 = BTMSketchConstraint2(
        constraint_type="COINCIDENT",
        parameters=[point_string_param, line_end_string_param],
        entity_id="constrainId",
        bt_type="BTMSketchConstraint-2",
    )
    coincident_constraint2 = BTMSketchConstraint2(
        constraint_type="LENGTH",
        parameters=[point_string_param, line_end_string_param, length],
        entity_id="constrainId",
        bt_type="BTMSketchConstraint-2",
    )
    point = BTMSketchPoint158(
        y=0.0, x=0.0, is_user_point=True, is_construction=False
    )
    point2 = BTMSketchPoint158(
        y=.0254, x=0.0, is_user_point=True, is_construction=False
    )
    point3 = BTMSketchPoint158(
        y=.0254, x=.0254, is_user_point=True, is_construction=False
    )
    point4 = BTMSketchPoint158(
        y=0.0, x=.0254, is_user_point=True, is_construction=False
    )
    line_geometry1 = BTCurveGeometryLine117(
        pnt_x=0.0, pnt_y=0.0, dir_x=0.0, dir_y=.0254, bt_type="BTCurveGeometryLine-117"
    )
    line_geometry2 = BTCurveGeometryLine117(
        pnt_x=0.0, pnt_y=.0254, dir_x=.0254, dir_y=0.0, bt_type="BTCurveGeometryLine-117"
    )
    line_geometry3 = BTCurveGeometryLine117(
        pnt_x=.0254, pnt_y=.0254, dir_x=0.0, dir_y=-.0254, bt_type="BTCurveGeometryLine-117"
    )
    line_geometry4 = BTCurveGeometryLine117(
        pnt_x=.0254, pnt_y=0.0, dir_x=-.0254, dir_y=0.0, bt_type="BTCurveGeometryLine-117"
    )
    line = BTMSketchCurveSegment155(
        start_point_id=f"LINE1.start",
        end_point_id=f"LINE1.end",
        start_param=0.0,
        end_param=1.0,
        geometry=line_geometry1,
        entity_id='LINE1',
        bt_type="BTMSketchCurveSegment-155",
    )
    line2 = BTMSketchCurveSegment155(
        start_point_id=f"LINE2.start",
        end_point_id=f"LINE2.end",
        start_param=0.0,
        end_param=1.0,
        geometry=line_geometry2,
        entity_id='LINE2',
        bt_type="BTMSketchCurveSegment-155",
    )
    line3 = BTMSketchCurveSegment155(
        start_point_id=f"LINE3.start",
        end_point_id=f"LINE3.end",
        start_param=0.0,
        end_param=1.0,
        geometry=line_geometry3,
        entity_id='LINE3',
        bt_type="BTMSketchCurveSegment-155",
    )
    line4 = BTMSketchCurveSegment155(
        start_point_id=f"LINE4.start",
        end_point_id=f"LINE4.end",
        start_param=0.0,
        end_param=1.0,
        geometry=line_geometry4,
        entity_id='LINE4',
        bt_type="BTMSketchCurveSegment-155",
    )
  
    sketch = BTMSketch151(
        entities=[line, line2, line3, line4],
        name="Square",
        parameters=[plane_query, length],
        constraints=[coincident_constraint1, coincident_constraint2],
        bt_type="BTMSketch-151",
    )
    feature_definition = BTFeatureDefinitionCall1406(feature=sketch)
    client.part_studios_api.add_part_studio_feature(
        did=part_studio.did,
        wvm=part_studio.wvm,
        wvmid=part_studio.wvmid,
        eid=part_studio.eid,
        bt_feature_definition_call_1406=feature_definition,
        _preload_content=False,
    )
Exemplo n.º 4
0
                              geometry=BTCurveGeometryLine117(
                                  pnt_x=0.0254,
                                  pnt_y=0.0,
                                  dir_x=-0.0254,
                                  dir_y=0.0,
                                  bt_type="BTCurveGeometryLine-117"),
                              entity_id="LINE4",
                              bt_type="BTMSketchCurveSegment-155"),
 ],
 name="Square",
 parameters=[
     BTMParameterQueryList148(
         parameter_id="sketchPlane",
         queries=[BTMIndividualQuery138(deterministic_ids=['JDC'])]),
     BTMParameterQuantity147(expression="1*in",
                             parameter_id="length",
                             bt_type="BTMParameterQuantity-147"),
 ],
 constraints=[
     BTMSketchConstraint2(
         constraint_type="COINCIDENT",
         parameters=[
             BTMParameterString149(value="point1",
                                   parameter_id="localFirst",
                                   bt_type="BTMParameterString-149"),
             BTMParameterString149(value="'LINE1.start",
                                   parameter_id="localSecond",
                                   bt_type="BTMParameterString-149"),
         ],
         entity_id="constrainId",
         bt_type="BTMSketchConstraint-2"),
Exemplo n.º 5
0
def extrude_remove_circle(client, part_studio):
    # square(client,part_studio)
    tool_body_type = BTMParameterEnum145(
        value="SOLID", enum_name="ToolBodyType", parameter_id="bodyType"
    )
    operation_domain = BTMParameterEnum145(
        value="MODEL",
        enum_name="OperationDomain",
        parameter_id="domain",
    ) 
    toolbodytype = BTMParameterEnum145(
        value="REMOVE",
        enum_name="NewBodyOperationType",
        parameter_id="operationType",
    )
    operationtype = BTMParameterEnum145(
        value="NEW",
        enum_name="NewSurfaceOperationType",
        parameter_id="surfaceOperationType",
    )
    boundingtype = BTMParameterEnum145(
        value="BLIND",
        enum_name="BoundingType",
        parameter_id="endBound",
    )
    flat = BTMParameterEnum145(
        value="REMOVE",
        enum_name="FlatOperationType",
        parameter_id="flatOperationType",
    )
    blind = BTMParameterEnum145(
        value="BLIND",
        enum_name="SecondDirectionBoundingType",
        parameter_id="secondDirectionBound",
    )

    line_query = BTMParameterQueryList148(
        parameter_id="entities",
        queries=[BTMIndividualQuery138(deterministic_ids=["JJC"])],
    )
    query = BTMParameterQueryList148(
        parameter_id="surfaceEntities",
        queries=[],
    )
    other_query = BTMParameterQueryList148(
        parameter_id="booleanScope",
        queries=[BTMIndividualQuery138(deterministic_ids=["JHD"])],
    )
    scope = BTMParameterQueryList148(
        parameter_id="booleanSurfaceScope",
        queries=[],
    )
    query2 = BTMParameterQueryList148(
        parameter_id="endBoundEntityFace",
        queries=[],
    )
    query3 = BTMParameterQueryList148(
        parameter_id="endBoundEntityBody",
        queries=[],
    )
    query4 = BTMParameterQueryList148(
        parameter_id="endBoundEntityVertex",
        queries=[],
    )
    
    length = BTMParameterQuantity147(expression="1 in", parameter_id="depth")
    offset = BTMParameterQuantity147(expression="1 in", parameter_id="offsetDistance")
    ffset = BTMParameterQuantity147(expression="1 in", parameter_id="secondDirectionDepth")
    extrude_feature = BTMFeature134(
        bt_type="BTMFeature-134",
        name="Extrude Remove Circle",
        feature_type="extrude",
        parameters=[operation_domain, tool_body_type, toolbodytype, 
        			boundingtype, other_query, scope, offset, ffset, query,
        			operationtype, flat, line_query, length],
    )
    feature_definition = BTFeatureDefinitionCall1406(feature=extrude_feature)
    client.part_studios_api.add_part_studio_feature(
        did=part_studio.did,
        wvm=part_studio.wvm,
        wvmid=part_studio.wvmid,
        eid=part_studio.eid,
        bt_feature_definition_call_1406=feature_definition,
        _preload_content=False,
    )