HOW TO GIVE ANGLE BETWEEN LINE IN FUSION 360

HOW TO GIVE ANGLE BETWEEN LINE IN FUSION 360

sHubamyadav016
Enthusiast Enthusiast
864 Views
14 Replies
Message 1 of 15

HOW TO GIVE ANGLE BETWEEN LINE IN FUSION 360

sHubamyadav016
Enthusiast
Enthusiast
[ The subject
0 Likes
865 Views
14 Replies
Replies (14)
Message 2 of 15

mufuo
Advocate
Advocate

Could you try the code below?

 

import adsk.core, adsk.fusion, traceback, math

def create_and_extrude_panel():
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)

    if not design:
        ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
        return

    # Create a new component for the panel.
    root_comp = design.rootComponent
    new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    panel_comp = new_comp.component

    # Create a new sketch for the panel profile.
    sketches = panel_comp.sketches
    xy_plane = panel_comp.xYConstructionPlane
    panel_sketch = sketches.add(xy_plane)

    # Define the corners of the panel profile.
    corner1 = adsk.core.Point3D.create(0, 0, 0)
    corner2 = adsk.core.Point3D.create(0, 1588, 0)
    corner3 = adsk.core.Point3D.create(200, 1717, 0)
    corner4 = adsk.core.Point3D.create(200, 0, 0)

    # Create lines connecting the corners to form the panel profile.
    lines = panel_sketch.sketchCurves.sketchLines

    # Define the angles between the lines.
    angle1 = 123
    angle2 = 57

    # Create the lines with the specified angles.
    line1 = lines.addByTwoPoints(corner1, corner2, angle1)
    line2 = lines.addByTwoPoints(corner2, corner3, angle2)
    line3 = lines.addByTwoPoints(corner3, corner4)
    line4 = lines.addByTwoPoints(corner4, corner1)

    # Extrude the panel profile to create a solid body.
    bodies = panel_comp.bRepBodies
    panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody)

    return panel_comp

# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()

 


Mustafa Furkan Özel
Project - R&D Manager

LinkedIn

0 Likes
Message 3 of 15

sHubamyadav016
Enthusiast
Enthusiast

File "C:/Users/RND7/Desktop/CHECKING/Untitled-1.py", line 35, in create_and_extrude_panel

line1 = lines.addByTwoPoints(corner1, corner2, angle1)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: SketchLines.addByTwoPoints() takes 3 positional arguments but 4 were given

i am getting error 

 

0 Likes
Message 4 of 15

sHubamyadav016
Enthusiast
Enthusiast

please see the drwing please tell me the project how can i make profile with drawing

 

0 Likes
Message 5 of 15

mufuo
Advocate
Advocate

I think it will work this time.

 

import adsk.core, adsk.fusion, traceback, math

def create_and_extrude_panel():
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)

    if not design:
        ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
        return

    # Create a new component for the panel.
    root_comp = design.rootComponent
    new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    panel_comp = new_comp.component

    # Create a new sketch for the panel profile.
    sketches = panel_comp.sketches
    xy_plane = panel_comp.xYConstructionPlane
    panel_sketch = sketches.add(xy_plane)

    # Define the corners of the panel profile.
    corner1 = adsk.core.Point3D.create(0, 0, 0)
    corner2 = adsk.core.Point3D.create(0, 1588, 0)
    corner3 = adsk.core.Point3D.create(200, 1717, 0)
    corner4 = adsk.core.Point3D.create(200, 0, 0)

    # Create lines connecting the corners to form the panel profile.
    lines = panel_sketch.sketchCurves.sketchLines

    # Define the angles between the lines.
    angle1 = 123
    angle2 = 57

    # Create the lines with the specified angles.
    line1 = lines.addByTwoPoints(corner1, corner2)
    line2 = lines.addByTwoPoints(corner2, corner3)
    line3 = lines.addByTwoPoints(corner3, corner4)
    line4 = lines.addByTwoPoints(corner4, corner1)

    # Extrude the panel profile to create a solid body.
    bodies = panel_comp.bRepBodies
    panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody)

    return panel_comp

# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()

 


Mustafa Furkan Özel
Project - R&D Manager

LinkedIn

0 Likes
Message 6 of 15

sHubamyadav016
Enthusiast
Enthusiast

NO It is not working please once see the drawing  please help me how to draw these angles please sir 

0 Likes
Message 7 of 15

sHubamyadav016
Enthusiast
Enthusiast
NO IT IS NOT WORKING THIS TIME ALSO
0 Likes
Message 8 of 15

mufuo
Advocate
Advocate

Do you want a code or is the drawing file enough?


Mustafa Furkan Özel
Project - R&D Manager

LinkedIn

0 Likes
Message 9 of 15

sHubamyadav016
Enthusiast
Enthusiast

I WANT CODE PLEASE HELP ME 

0 Likes
Message 10 of 15

sHubamyadav016
Enthusiast
Enthusiast
I want code
0 Likes
Message 11 of 15

mufuo
Advocate
Advocate

Finally, I created 2 more codes. If one of them does not work, there is nothing else I can do.

 

Option 1

 

import adsk.core, adsk.fusion, traceback, math

def create_and_extrude_panel():
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)

    if not design:
        ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
        return

    # Create a new component for the panel.
    root_comp = design.rootComponent
    new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    panel_comp = new_comp.component

    # Create a new sketch for the panel profile.
    sketches = panel_comp.sketches
    xy_plane = panel_comp.xYConstructionPlane
    panel_sketch = sketches.add(xy_plane)

    # Define the corners of the panel profile.
    corner1 = adsk.core.Point3D.create(0, 0, 0)
    corner2 = adsk.core.Point3D.create(0, 1588, 0)
    corner3 = adsk.core.Point3D.create(200, 1717, 0)
    corner4 = adsk.core.Point3D.create(200, 0, 0)

    # Create lines connecting the corners to form the panel profile.
    lines = panel_sketch.sketchCurves.sketchLines

    # Define the angles between the lines.
    angle1 = math.radians(123)
    angle2 = math.radians(57)

    # Create the lines with the specified angles.
    line1 = lines.addByTwoPoints(corner1, corner2, angle1)
    line2 = lines.addByTwoPoints(corner2, corner3, angle2)
    line3 = lines.addByTwoPoints(corner3, corner4)
    line4 = lines.addByTwoPoints(corner4, corner1)

    # Extrude the panel profile to create a solid body.
    bodies = panel_comp.bRepBodies
    panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody)

    return panel_comp

# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()

 

Option 2

 

import adsk.core, adsk.fusion, traceback, math

def create_and_extrude_panel():
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)

    if not design:
        ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
        return

    # Create a new component for the panel.
    root_comp = design.rootComponent
    new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    panel_comp = new_comp.component

    # Create a new sketch for the panel profile.
    sketches = panel_comp.sketches
    xy_plane = panel_comp.xYConstructionPlane
    panel_sketch = sketches.add(xy_plane)

    # Define the corners of the panel profile.
    corner1 = adsk.core.Point3D.create(0, 0, 0)
    corner2 = adsk.core.Point3D.create(0, 1588, 0)
    corner3 = adsk.core.Point3D.create(200, 1717, 0)
    corner4 = adsk.core.Point3D.create(200, 0, 0)

    # Create lines connecting the corners to form the panel profile.
    lines = panel_sketch.sketchCurves.sketchLines

    # Define the angles between the lines.
    angle1 = math.radians(123)
    angle2 = math.radians(57)

    # Create the lines with the specified angles.
    line1 = lines.addByTwoPoints(corner1, corner2, angle1)
    line2 = lines.addByTwoPoints(corner2, corner3, angle2)
    line3 = lines.addByTwoPoints(corner3, corner4, angle1)
    line4 = lines.addByTwoPoints(corner4, corner1, angle2)

    # Extrude the panel profile to create a solid body.
    bodies = panel_comp.bRepBodies
    panel_body = bodies.add(panel_sketch, adsk.fusion.FeatureOperation.NewBody, 50, adsk.fusion.BodyAppearance.Smooth)

    return panel_comp

# Call the function to create and extrude the panel.
panel_comp = create_and_extrude_panel()

 


Mustafa Furkan Özel
Project - R&D Manager

LinkedIn

0 Likes
Message 12 of 15

sHubamyadav016
Enthusiast
Enthusiast

Bro both of your code is not working

0 Likes
Message 13 of 15

mufuo
Advocate
Advocate

I made one last attempt not to leave you alone.

 

import adsk.core, adsk.fusion, traceback, math

def create_and_extrude_shape():
    app = adsk.core.Application.get()
    design = adsk.fusion.Design.cast(app.activeProduct)

    if not design:
        ui.messageBox('It is not supported in the current workspace. Please change to the MODEL workspace and try again.')
        return

    # Create a new component for the shape.
    root_comp = design.rootComponent
    new_comp = root_comp.occurrences.addNewComponent(adsk.core.Matrix3D.create())
    shape_comp = new_comp.component

    # Create a new sketch for the shape profile.
    sketches = shape_comp.sketches
    xy_plane = shape_comp.xYConstructionPlane
    shape_sketch = sketches.add(xy_plane)

    # Define the corners of the shape profile.
    corner1 = adsk.core.Point3D.create(0, 0, 0)
    corner2 = adsk.core.Point3D.create(0, 1588, 0)
    corner3 = adsk.core.Point3D.create(200, 1717, 0)
    corner4 = adsk.core.Point3D.create(200, 0, 0)

    # Create lines connecting the corners to form the shape profile.
    lines = shape_sketch.sketchCurves.sketchLines

    # Create the lines with the specified angles.
    line1 = lines.addByTwoPoints(corner1, corner2, 123)
    line2 = lines.addByTwoPoints(corner2, corner3, 57)
    line3 = lines.addByTwoPoints(corner3, corner4, 123)
    line4 = lines.addByTwoPoints(corner4, corner1, 57)

    # Extrude the shape profile to create a solid body.
    bodies = shape_comp.bRepBodies
    shape_body = bodies.add(shape_sketch, adsk.fusion.FeatureOperation.NewBody, 50, adsk.fusion.BodyAppearance.Smooth)

    return shape_comp

# Call the function to create and extrude the shape.
shape_comp = create_and_extrude_shape()

 


Mustafa Furkan Özel
Project - R&D Manager

LinkedIn

0 Likes
Message 14 of 15

sHubamyadav016
Enthusiast
Enthusiast

you are doing same error in every program 

 you are defining add two points and also also giving angle it is acceptabel than your giving me precious time

line1 = lines.addByTwoPoints(corner1, corner2, 123)
0 Likes
Message 15 of 15

sHubamyadav016
Enthusiast
Enthusiast
Sir you really helped me and gave me your precious time but you did not see the drawing attached with my question and in every program only one error and same error you can not define add by two point with three values I sent you errot but you are repeation same error in every response .
thank you
0 Likes