Custom graphics is not showing points

Custom graphics is not showing points

mike46YZU
Contributor Contributor
463 Views
2 Replies
Message 1 of 3

Custom graphics is not showing points

mike46YZU
Contributor
Contributor

Hi,

 

I've been working with custom graphics and managed to draw lines, now I'm attempting to draw some points in a similar way, but they do not appear after refreshing the view. I placed my TestPoint.png in the root directory of my python add-in script. Here's the function I made that is supposed to draw the points. I'm probably overlooking something obvious, but I cannot find it. Any clue?

def draw_points():
    app = adsk.core.Application.get()
    view = app.activeViewport

    #delete all custom graphics groups
    cnt = root.customGraphicsGroups.count
    if  cnt > 0:
        for i in range(cnt):     
            root.customGraphicsGroups.item(i).deleteMe()
    
    graphics = root.customGraphicsGroups.add()
    coordArray = [10,0,0,-10,0,0]
    pointIndices = [0,1]
    coords = adsk.fusion.CustomGraphicsCoordinates.create(coordArray)
    points = graphics.addPointSet(coords, pointIndices, adsk.fusion.CustomGraphicsPointTypes.UserDefinedCustomGraphicsPointType,'TestPoint.png')

    view.refresh()
0 Likes
Accepted solutions (1)
464 Views
2 Replies
Replies (2)
Message 2 of 3

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi @mike46YZU ,

 

Your code works at my side.

I believe your problem is with the path of the file.

 

You can try two options:

1. Put the full path of the .png file just to checks it could load it.

2. Check that you .png is in the same directory as the .py script, but not on the add-in's root directory as you wrote.

 

Regards,

Jorge Jaramillo

Software Engineer

0 Likes
Message 3 of 3

mike46YZU
Contributor
Contributor

The image file was located next to the python script itself, then it did not work. I now changed the path to an absolute path, then it worked. For my application I need to get it to work with a relative path, I'll try out some other locations. 

0 Likes