{"id":24310368,"url":"https://github.com/hisarcs/f360","last_synced_at":"2025-03-08T00:31:22.406Z","repository":{"id":230207121,"uuid":"724510738","full_name":"HisarCS/F360","owner":"HisarCS","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-21T11:28:53.000Z","size":1205,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-17T06:13:43.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HisarCS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-28T08:22:04.000Z","updated_at":"2024-11-21T11:28:57.000Z","dependencies_parsed_at":"2024-05-22T11:47:34.783Z","dependency_job_id":"fd489b1a-376f-49ac-b21d-b7ee287ca3f8","html_url":"https://github.com/HisarCS/F360","commit_stats":null,"previous_names":["hisarcs/f360"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HisarCS%2FF360","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HisarCS%2FF360/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HisarCS%2FF360/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HisarCS%2FF360/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HisarCS","download_url":"https://codeload.github.com/HisarCS/F360/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242483273,"owners_count":20135784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-17T06:13:49.043Z","updated_at":"2025-03-08T00:31:22.381Z","avatar_url":"https://github.com/HisarCS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# F360\n\nThese are a set of classes created with the goal of making it easier to work with the API of fuison 360. These classes simplify the code you have to write and reduce the lines of code you must write to achive your end result\n\n# How to use the Classes \n\nThis section will educate you on the usage of the classes in Fusion 360. \n\n## Sketching\n\nLet us begin with the most simple sketch: A SINGULAR LINE\n\n### The Line Class\n```python\n\nstart_point = adsk.core.Point3D.create(0, 0, 0)\nend_point = adsk.core.Point3D.create(10, 0, 0)\n\nxy_plane = app.activeProduct.rootComponent.xYConstructionPlane\n       \nline_drawer = LineDrawer(start_point, end_point, xy_plane)\n\nline_drawer.create_line()\n\n```\n\nTo explain the code: You simply define your start and end point, construction plane and create the LineDrawer class instance. After that you call the create_line function and you have a line on any plane you want. ⎹ \n\u003cimg width=\"628\" alt=\"Ekran Resmi 2023-11-29 18 06 24\" src=\"https://github.com/HisarCS/F360/assets/120194760/78cdb822-9620-487b-8af4-fa7ba08dfc44\"\u003e\n\n### The Circle Class\n\nLet's look at how to create a circle with the circle class\n\n```python\n\napp = adsk.core.Application.get()\nui = app.userInterface\n\ndesign = app.activeProduct\nrootComp = design.rootComponent\n\nxzPlane = rootComp.xZConstructionPlane\ncircle_creator = CircleCreator(adsk.core.Point3D.create(0, 0, 0), 2, xyPlane)\n\ncircle1 = circle_creator.create_circle()\n\n```\nHere you have to define the application and ui(they aren't defined in the class). Then create a variable and assign the construction plane you want to use to it. After that you just have to define your point and radius and pass them into the class along with the plane the circle will be drawn on.  ⃝\n\n\u003cimg width=\"485\" alt=\"Ekran Resmi 2023-11-29 18 06 59\" src=\"https://github.com/HisarCS/F360/assets/120194760/d0f68bcf-a3e2-40e2-94e5-16ffe1ba2e6e\"\u003e\n\n### The Rectangle Class\n\n```python\n\napp = adsk.core.Application.get()\nui = app.userInterface\n\n       \ncorner1 = adsk.core.Point3D.create(0, 0, 0)\ncorner2 = adsk.core.Point3D.create(10, 5, 0)\n\n\nxy_plane = app.activeProduct.rootComponent.xYConstructionPlane\n\nrectangle_drawer = RectangleDrawer(corner1, corner2, xy_plane)\n\nrectangle_drawer.draw_rectangle()\n```\nHere you have to define the application and ui(they aren't defined in the class). Then you have to define two points as you are drawing a two point rectangle also you define the plane you use then you pass them into the class. After that you just have to call the draw_rectangle function and you have a rectangle.▭\n\n\u003cimg width=\"483\" alt=\"Ekran Resmi 2023-11-29 18 07 22\" src=\"https://github.com/HisarCS/F360/assets/120194760/7110dab2-7a78-4443-89cf-466fb6fc8cc5\"\u003e\n\n### The Polygon Class\n\n\n```python\n\napp = adsk.core.Application.get()\nui = app.userInterface\n\ncenter_point = adsk.core.Point3D.create(0, 0, 0)\nnum_sides = 6\nradius = 3\nxy_plane = app.activeProduct.rootComponent.xYConstructionPlane\n\npolygon_drawer = PolygonDrawer(center_point, num_sides, radius, xy_plane)\npolygon_drawer.draw_polygon()\n```\nHere you have to define the application and ui(they aren't defined in the class). Then you have to define your side number, radius, plane and center point. After that you pass these into the class and then class the draw_polygon function and you have a polygon. ⬠\n\n\u003cimg width=\"487\" alt=\"Ekran Resmi 2023-11-29 18 07 55\" src=\"https://github.com/HisarCS/F360/assets/120194760/20b24308-7bbd-47fe-8e5e-5052183f97c8\"\u003e\n\n### Three Point Arc\n\n```python\n\napp = adsk.core.Application.get()\nui = app.userInterface\n\ndesign = app.activeProduct\nroot_comp = design.rootComponent\n\nxy_plane = root_comp.xYConstructionPlane\n\narc_creator = ThreePointArcCreator(xy_plane)\n\npoint1 = adsk.core.Point3D.create(0, 0, 0)\npoint2 = adsk.core.Point3D.create(10, 0, 0)\npoint3 = adsk.core.Point3D.create(10, 10, 0)\n\narc_creator.create_arc(point1, point2, point3)\n\n```\n\nHere you call/define app and ui also you get the design and root_comp after that you define the xy plane you then create an instance of the class and pass in the plane after that you call the create_arc function and pass in the points. After you've completed these steps you have a three point arc. ⌒\n\n\u003cimg width=\"820\" alt=\"Ekran Resmi 2023-11-30 00 37 06\" src=\"https://github.com/HisarCS/F360/assets/120194760/61a8a6b3-502a-4a75-a046-1ded8636ce46\"\u003e\n\n\n## The ELlipse Class\n\n```python\nimport adsk.core, adsk.fusion, adsk.cam, traceback\n\nclass EllipseDrawer:\n    def __init__(self, app):\n        self.app = app\n        self.ui = app.userInterface\n        self.design = app.activeProduct\n        self.rootComp = self.design.rootComponent\n\n    def draw_ellipse(self, plane_name, center_x, center_y, major_axis_length, minor_axis_length):\n        if plane_name.lower() == 'xy':\n            plane = self.rootComp.xYConstructionPlane\n        elif plane_name.lower() == 'xz':\n            plane = self.rootComp.xZConstructionPlane\n        elif plane_name.lower() == 'yz':\n            plane = self.rootComp.yZConstructionPlane\n        else:\n            self.ui.messageBox(f\"Plane {plane_name} not recognized. Please use 'XY', 'XZ', or 'YZ'.\")\n            return\n        \n        sketches = self.rootComp.sketches\n        sketch = sketches.add(plane)\n        center = adsk.core.Point3D.create(center_x, center_y, 0)\n        major_axis_point = adsk.core.Point3D.create(center_x + major_axis_length / 2, center_y, 0)\n        \n        # Calculate a point on the minor axis\n        if plane_name.lower() == 'xy' or plane_name.lower() == 'xz':\n            minor_axis_point = adsk.core.Point3D.create(center_x, center_y + minor_axis_length / 2, 0)\n        else: # 'YZ' plane\n            minor_axis_point = adsk.core.Point3D.create(0, center_y + minor_axis_length / 2, center_x)\n        \n        sketch.sketchCurves.sketchEllipses.add(center, major_axis_point, minor_axis_point)\n        self.ui.messageBox(f'Ellipse drawn successfully on the {plane_name} plane!')\n\n\n\n```\n\n## Features\n\n### Extrude \n\n```python\n\napp = adsk.core.Application.get()\nui = app.userInterface\n\n\nsketches = app.activeProduct.rootComponent.sketches\nxy_plane = app.activeProduct.rootComponent.xYConstructionPlane\nsketch = sketches.add(xy_plane)\n\n \ncorner1 = adsk.core.Point3D.create(0, 0, 0)\ncorner2 = adsk.core.Point3D.create(10, 5, 0)\nsketch.sketchCurves.sketchLines.addTwoPointRectangle(corner1, corner2)\n\n        \nrectangle_profile = sketch.profiles.item(0)  \nextrude_creator = ExtrudeCreator(rectangle_profile, 5, 'NewBody')\n\n     \nextrude_creator.create_extrusion()\n\n```\nFirstly here you create a simple shape(here a rectangle). Then you put your profile the extrusion height and type into the class. After that you just called the creat extrusion function and now you have a 3D body.\n\n\u003cimg width=\"772\" alt=\"Ekran Resmi 2023-12-07 07 24 55\" src=\"https://github.com/HisarCS/F360/assets/120194760/4ada3ae5-abc4-4df5-8d3d-0ffb5e5de9de\"\u003e\n\n### Fillet\n\n#### Constant Radius Fillet\n\n#### Variable Radius Fillet\n\n#### Chord Length Fillet\n\n### Loft\n\n```python\ndef run(context):\n    try:\n        app = adsk.core.Application.get()\n        lofter = Lofter(app)\n\n        def sketch_square1(sketch):\n            lines = sketch.sketchCurves.sketchLines\n            p1 = adsk.core.Point3D.create(-2.5, 2.5, 0)\n            p2 = adsk.core.Point3D.create(2.5, 2.5, 0)\n            p3 = adsk.core.Point3D.create(2.5, -2.5, 0)\n            p4 = adsk.core.Point3D.create(-2.5, -2.5, 0)\n            lines.addByTwoPoints(p1, p2)\n            lines.addByTwoPoints(p2, p3)\n            lines.addByTwoPoints(p3, p4)\n            lines.addByTwoPoints(p4, p1)\n\n        xyPlane = lofter.rootComp.xYConstructionPlane\n        lofter.add_profile(xyPlane, sketch_square1)\n\n        def sketch_square2(sketch):\n            lines = sketch.sketchCurves.sketchLines\n            p1 = adsk.core.Point3D.create(-1.5, 1.5, 0)\n            p2 = adsk.core.Point3D.create(1.5, 1.5, 0)\n            p3 = adsk.core.Point3D.create(1.5, -1.5, 0)\n            p4 = adsk.core.Point3D.create(-1.5, -1.5, 0)\n            lines.addByTwoPoints(p1, p2)\n            lines.addByTwoPoints(p2, p3)\n            lines.addByTwoPoints(p3, p4)\n            lines.addByTwoPoints(p4, p1)\n\n        offsetPlaneInput = lofter.rootComp.constructionPlanes.createInput()\n        offsetDistance = adsk.core.ValueInput.createByReal(10.0)\n        offsetPlaneInput.setByOffset(xyPlane, offsetDistance)\n        offsetPlane = lofter.rootComp.constructionPlanes.add(offsetPlaneInput)\n        lofter.add_profile(offsetPlane, sketch_square2)\n\n        lofter.create_loft()\n\n    except:\n        if lofter.ui:\n            lofter.ui.messageBox('Failed:\\n{}'.format(traceback.format_exc()))\n\n\n```\n\n\u003cimg width=\"1005\" alt=\"Ekran Resmi 2024-03-28 14 46 19\" src=\"https://github.com/HisarCS/F360/assets/120194760/1b68f405-e126-4022-81f6-fcec6dfe9a3b\"\u003e\n\n\n\n### Chamfer\n\n\n```python\ndef run(context):\n    try:\n        app = adsk.core.Application.get()\n        chamfer_creator = ChamferCreator(app)\n        \n        # Find the first solid body in the root component to demonstrate chamfering its edges\n        rootComp = chamfer_creator.design.rootComponent\n        bodies = rootComp.bRepBodies\n        if bodies.count \u003e 0:\n            body = bodies.item(0)\n            edges = body.edges\n            if edges.count \u003e= 2:\n                # Attempt to chamfer the first two edges of the body\n                chamfer_edges = [edges.item(0), edges.item(1)]\n                chamfer_distance = 0.5  # Specify the chamfer distance\n                chamfer_creator.create_chamfer(chamfer_edges, chamfer_distance)\n            else:\n                chamfer_creator.ui.messageBox('Not enough edges to create a chamfer.')\n        else:\n            chamfer_creator.ui.messageBox('No solid bodies found in the root component.')\n        \n    except:\n        if chamfer_creator.ui:\n            chamfer_creator.ui.messageBox('Failed:\\n{}'.format(traceback.format_exc()))\n\n```\n\u003cimg width=\"800\" alt=\"Ekran Resmi 2024-03-28 16 02 41\" src=\"https://github.com/HisarCS/F360/assets/120194760/85a38b2e-cd5c-4e33-89fb-b56f261c56af\"\u003e\n\n\n### Offset \n\n```python\n\ndef run(context):\n    try:\n        app = adsk.core.Application.get()\n        offset_creator = OffsetCreator(app)\n        xyPlane = offset_creator.rootComp.xYConstructionPlane\n        sketch = offset_creator.rootComp.sketches.add(xyPlane)\n        circle = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), 5)\n        offset_distance = 1.0\n        direction_point = (0, 0, 0)  # Use the center of the circle as the direction point\n        offset_creator.create_offset(sketch, [circle], offset_distance, direction_point)\n    except:\n        if offset_creator.ui:\n            offset_creator.ui.messageBox('Failed:\\n{}'.format(traceback.format_exc()))\n\n\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisarcs%2Ff360","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhisarcs%2Ff360","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhisarcs%2Ff360/lists"}