Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to create lines at joint point

xusho
Autodesk

How to create lines at joint point

xusho
Autodesk
Autodesk

I am trying to create a sketch by adding points and lines by API. The intention is to let the 3 lines below share a point at the blue joint. It seems when a new line is added, new end points are always created separately. Is it possible to use an existing point to create a new line without duplicating the point?

xusho_0-1658299007841.png

 

Shoudong Xu
Autodesk Moldflow Meshing
Shoudong.Xu@autodesk.com
0 Likes
Reply
Accepted solutions (2)
360 Views
4 Replies
Replies (4)

Rushikesh.kadam
Autodesk
Autodesk

@xusho I believe passing the existing SketchPoint while creating the line will do the trick.

A sample script of what you are trying to achieve will help to understand the case?

 

Regards,




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.


0 Likes

xusho
Autodesk
Autodesk

Hi Rushikesh,
Thanks for your reply.

I have points and lines in json. My intention is to draw a sketch in F360:

This is my code:

with
open(input_filename) as json_file:
        json_data = json.load(json_file)

    # Create sketch points
    # points are created and saved as a map
    point_map = {}
    for point in json_data['points']:
        p_id = point['id']
        xyz = point['xyz']
        point = adsk.core.Point3D.create(float(xyz[0]), float(xyz[1]), float(xyz[2]))
        sketchPoints.add(point)
        point_map[p_id] = point

    for ent in json_data['entities']:
        ent_id = ent['id']
        ent_type = ent['type']
        if ent_type == 'line':  # line
            p0_id = ent['attributes']['startPointId']
            p1_id = ent['attributes']['endPointId']
            # get point from id. Points can be shaed by several lines.
            p0 = point_map[p0_id]
            p1 = point_map[p1_id]
            sketchLines.addByTwoPoints(p0, p1)
 
After drawing, I expect to stretch the shape when dragging one line (blue), but actually only one line will move, while others do not move. It seems they are not joined.
xusho_0-1658301996531.png

Is it possible to make lines joined like a rectangle?
Thanks
Shoudong

Shoudong Xu
Autodesk Moldflow Meshing
Shoudong.Xu@autodesk.com
0 Likes

kandennti
Mentor
Mentor
Accepted solution

Hi @xusho .

 

This way, I think it will be as desired.

・・・
        point = adsk.core.Point3D.create(float(xyz[0]), float(xyz[1]), float(xyz[2]))
        sktPoint = sketchPoints.add(point)
        point_map[p_id] = sktPoint
・・・
1 Like

xusho
Autodesk
Autodesk
Accepted solution

Yes. It works now. Thank you very much, Rushikesh.

Shoudong Xu
Autodesk Moldflow Meshing
Shoudong.Xu@autodesk.com
0 Likes