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

Unable to run Entitlement API sample

obatake5TC3R
Advocate

Unable to run Entitlement API sample

obatake5TC3R
Advocate
Advocate

I try to download and run the Entitlement API, but I can't.The situation is the same for both C++ and Python.

The download destination is here.

I can do this by commenting out the Python import.

C++ is the same.  (Use VisualStdio 2019 V16.6.4)

I have no idea what to do..

0 Likes
Reply
284 Views
1 Reply
Reply (1)

kandennti
Mentor
Mentor

I will write in Japanese, but please do not move from the "API and Scripts" forum!!

 

@obatake5TC3R さん こんにちは

 

pythonで試してみました。

from .modules import requests

が外部ライブラリの読み込みなのですが、素のFusion360ではインストール

されていない為、動かないようです。

 

標準ライブラリで書き換えた所、動きました。

(元のコードはアドインでしたが、書き換えたものはスクリプトです)

#Fusion360API python script
import adsk.core, adsk.fusion, traceback
import json
import urllib.request

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        userId = app.userId
        appId ="1006119760063675415"
        url  = "https://apps.exchange.autodesk.com/webservices/checkentitlement" + "?userid=" + userId + "&appid=" + appId

        response = urllib.request.urlopen(url)
        html = response.read()
        resp_dict = json.loads(html)
        val = resp_dict.get('IsValid')

        if val:
            ui.messageBox("IsValid is True")
        else:
            ui.messageBox("IsValid is False")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

試してはいますが、対象となるアドインのライセンス?が無いので、

常に "IsValid is False" が返って来てしまい、正しい動作なのか? 不明なのが本音です。

 

結論から言えば、"url" に代入されているフォーマットでアクセスしてDLすると

必要となる情報をJSONフォーマットで落としてくるので、その後は

”自力で頑張れ!” との事の様です。

0 Likes