決まったフォーマットの文字列を出力する質問の様です。
Conversion of a simple Inventor VBA macro to Python - Autodesk Community
元のVBAのコードのセンスの無さ・・・。
あまり文字列をチマチマやったことが無かったので調べました。
[Python]文字列を空白埋めする(string fill with white space)には? | ちょげぶろぐ
この様な感じだと思います。
# Fusion360API Python script import traceback import adsk.core as core def run(context): ui: core.UserInterface = None try: app: core.Application = core.Application.get() ui = app.userInterface Quantity: str = "12" PartDescription = "TEST PART DESCRIPTION" # OutputString = OutputString & Space(22 - Len(OutputString)) & Space(4 - Len(Quantity)) & Quantity # OutputString = OutputString & Space(28 - Len(OutputString)) & PartDescription # OutputString = OutputString & Space(188 - Len(OutputString)) & "P" & " " & "T" # OutputString = OutputString.rjust(190 - 28) + PartDescription.rjust(28 - 4) + OutputString.rjust(22 - 4) + Quantity.rjust(4) OutputString = Quantity.rjust(26) + PartDescription.rjust(23) + 'P T'.rjust(142) print(OutputString) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
ExcelのVBAのDebug.Printした文字と合わせたので、ひょっとしたら全体がズレているかも。
この質問者さん、上手く行かないときは文句を言い、上手く行ったときは
黙っているので教えない事にしてます。
恐らくBOMを作っているのだと思います。(前から)