stepalibre
Alibre Super User
FYI,
While debugging the GPT, I noticed issues around Part() vs CurrentPart(). The solution for now is to not use CurrentPart() in the GPT or manually fix it. This creates other issues, being that another window is opened with the new Part(). This is very cumbersome not to mention OpenAI services and the GPT beta being very slow lately.
From the error I guess, the call to AlibreScript.API.Part.Add3DSketch(String Name) is failing under CurrentPart()?
CurrentPart() is missing from the examples so maybe it's not the same as Part(). Creating a new part file for a simple sketch or other simple test I'm doing is wrong. I need the same session in-order to troubleshoot the GPT and scripting in general.
ChatGPT generated code:
Failed
Works
While debugging the GPT, I noticed issues around Part() vs CurrentPart(). The solution for now is to not use CurrentPart() in the GPT or manually fix it. This creates other issues, being that another window is opened with the new Part(). This is very cumbersome not to mention OpenAI services and the GPT beta being very slow lately.
From the error I guess, the call to AlibreScript.API.Part.Add3DSketch(String Name) is failing under CurrentPart()?
CurrentPart() is missing from the examples so maybe it's not the same as Part(). Creating a new part file for a simple sketch or other simple test I'm doing is wrong. I need the same session in-order to troubleshoot the GPT and scripting in general.
ChatGPT generated code:
Failed
Python:
import math
from AlibreScript import *
part = CurrentPart()
sketch3D = part.Add3DSketch('My3DSketch')
if sketch3D is None:
raise Exception("Failed to create 3D sketch.")
sketch3D.StartEditing()
# Define start and end points of the line
startPoint = [0, 0, 0] # Replace x1, y1, z1 with your start point coordinates
endPoint = [10, 10, 10] # Replace x2, y2, z2 with your end point coordinates
# Add the line to the sketch
sketch3D.AddLine(startPoint, endPoint)
sketch3D.StopEditing()
print("Line added to 3D sketch successfully.")
>>>
Traceback (most recent call last):
File "<string>", line 4, in <module>
EnvironmentError: System.Runtime.InteropServices.COMException (0x8000FFFF): Object reference not set to an instance of an object.
at com.alibre.automation.ExceptionMap.handleException(Exception inputException)
at com.alibre.automation.Alibre3DSketches.Add3DSketch(String name)
at AlibreScript.API.Part.Add3DSketch(String Name)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at AlibreScript.UI.IronTextBoxControl.#9Gb(Object #FI)
>>>
Works
Python:
import math
from AlibreScript import *
part = Part('a_new_sk')
sketch3D = part.Add3DSketch('My3DSketch')
if sketch3D is None:
raise Exception("Failed to create 3D sketch.")
sketch3D.StartEditing()
# Define start and end points of the line
startPoint = [0, 0, 0] # Replace x1, y1, z1 with your start point coordinates
endPoint = [10, 10, 10] # Replace x2, y2, z2 with your end point coordinates
# Add the line to the sketch
sketch3D.AddLine(startPoint, endPoint)
sketch3D.StopEditing()
print("Line added to 3D sketch successfully.")
>>>
Line added to 3D sketch successfully.
>>>
APIs
Type->AlibreScript.API.Part
Method->Add3DSketch(String Name)
Type->AlibreScript.API.Sketch3D
Method->StartEditing()
Method->StopEditing()
Method->AddLine(List StartPoint, List EndPoint)
Method->AddPoint(Double X, Double Y, Double Z)
Last edited: