What's new

The Alibre Value is not available

kyleborot

Member
Hello all,

Dealing with an issue when trying to save to my M-File Vault through a SaveAs function. Here's the error:
<CODE>
Traceback (most recent call last):
File "<string>", line 124, in <module>
EnvironmentError: System.Runtime.InteropServices.COMException (0x80040328): The Alibre Vault is not available
at com.alibre.automation.ExceptionMap.handleException(Exception inputException)
at com.alibre.automation.AlibreSession.SaveAs(Object& destination, String itemName)
at AlibreScript.API.Part.SaveAs(String Folder, String NewName)
at Microsoft.Scripting.Interpreter.ActionCallInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.Scripting.Interpreter.DynamicInstruction`5.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)

</CODE>
This is how I'm trying to save it:
parts.SaveAs(r"M:\DMFTLAPPSRV\3. CAD Files\All CAD Files", ("KYLE BOROT TEST" + str(i)))

Any and all help is appreciated.
 

NateLiquidGravity

Alibre Super User
I remember discussion before that saving to vault/m-files from AlibreScript didn't work and I can't remember or find it the issue was resolved.

That said you wouldn't use the full "path" for m-files since the path is dynamic based on the metadata. Does this by chance work?
Python:
parts.SaveAs(r"M:\DMFTLAPPSRV", ("KYLE BOROT TEST" + str(i)))
 

kyleborot

Member
I remember discussion before that saving to vault/m-files from AlibreScript didn't work and I can't remember or find it the issue was resolved.

That said you wouldn't use the full "path" for m-files since the path is dynamic based on the metadata. Does this by chance work?
Python:
parts.SaveAs(r"M:\DMFTLAPPSRV", ("KYLE BOROT TEST" + str(i)))
This worked. However I'm running into a separate issue. I am saving a set of parts from an assembly, and then saving an assembly. But when I save the assembly rather than using my newly saved parts, the assembly uses the old template parts.

Python:
Assy.Regenerate()
print("MITER GENERATION COMPLETE\nGENERATING SAVES")
Assy.Save()
print("SAVED TEMPLATE")
for i in range(total_pieces):
    new_part_file_path = r"M:\DMFTLAPPSRV\"" + dwg_number + "MITER PART" + str(i+1)
    parts[i].SaveAs(r"M:\DMFTLAPPSRV", (dwg_number + " MITER PART " + str(i+1)))
    print("PART " + str(i+1) + " SAVED")
    # Verify file path for each part after saving
    current_part_file_path = parts[i].FilePath
    if new_part_file_path == current_part_file_path:
        print("Part " + str(i+1) + ": File path is correct")
    else:
        print("Part " + str(i+1) + ": File path is incorrect. Expected: {new_part_file_path}, Actual: {current_part_file_path}")
    print("----------------------------------------------------------------")
Assy.SaveAs(r"M:\DMFTLAPPSRV", (dwg_number + " MITER ASSY"))

Any thoughts on what may be causing this?
 

DavidJ

Administrator
Staff member
You may want to use SaveAll

Alibre Script: Assembly Class Reference
Save the assembly and all parts/sub-assemblies to a folder
 

kyleborot

Member
You may want to use SaveAll

Alibre Script: Assembly Class Reference
Save the assembly and all parts/sub-assemblies to a folder
According to the API documentation, SaveAll only takes the destination of the file. And I didn't see a way to directly rename the files individually. Is this the only way?
 

DavidJ

Administrator
Staff member
Sorry if I mis-understood.

You probably want an equivalent to 'Save All As' from the UI , so you can change names and maintain linkages. Maybe someone more experienced with script can advise...
 

stepalibre

Alibre Super User
This worked. However I'm running into a separate issue. I am saving a set of parts from an assembly, and then saving an assembly. But when I save the assembly rather than using my newly saved parts, the assembly uses the old template parts.

Python:
Assy.Regenerate()
print("MITER GENERATION COMPLETE\nGENERATING SAVES")
Assy.Save()
print("SAVED TEMPLATE")
for i in range(total_pieces):
    new_part_file_path = r"M:\DMFTLAPPSRV\"" + dwg_number + "MITER PART" + str(i+1)
    parts[i].SaveAs(r"M:\DMFTLAPPSRV", (dwg_number + " MITER PART " + str(i+1)))
    print("PART " + str(i+1) + " SAVED")
    # Verify file path for each part after saving
    current_part_file_path = parts[i].FilePath
    if new_part_file_path == current_part_file_path:
        print("Part " + str(i+1) + ": File path is correct")
    else:
        print("Part " + str(i+1) + ": File path is incorrect. Expected: {new_part_file_path}, Actual: {current_part_file_path}")
    print("----------------------------------------------------------------")
Assy.SaveAs(r"M:\DMFTLAPPSRV", (dwg_number + " MITER ASSY"))

Any thoughts on what may be causing this?
You likely need to save those renamed parts into (insert) a new assembly or a copy of the assembly currently in use.
 
Last edited:

stepalibre

Alibre Super User
I haven't found a safe and reliable way to rename or replace (update the part name or path) components with Alibre's APIs. I instead make a copy of an assembly and insert the new/renamed parts into the copy or a new assembly.
But when I save the assembly rather than using my newly saved parts, the assembly uses the old template parts.
The assembly is still referencing the old parts. We can't change the reference "in-place" how we would like to, therefore the need to insert the components into another assembly. A question is if the assembly or parts are inside M-Files how can you update it in this way? Is this an M-Files API procedure?
Sorry if I mis-understood.

You probably want an equivalent to 'Save All As' from the UI , so you can change names and maintain linkages. Maybe someone more experienced with script can advise...
Yes, this would be the solution to the problem if it were in API form. The hard linking of files which requires them to be fully loaded is a problem in other areas. A true proxy system would make lightweight assemblies and rename/replace in-place fast and possible. These are implementation details, I hope Alibre PDM will solve.

All that being said, I don't understand where the Alibre API and M-files API integration start and end. You're using SaveAs from Alibre Script but saving into M-Files? The M-Files API won't help here? I spent time with the M-Files API during Geomagic Design timeframe, it was full featured. Could't the SaveAs happen in the M-files API using the
VaultObjectFileOperations Object? I guess I'm confused about the workflow.
 
Top