What's new

Are Measurements for a Part Stored in a separate File?

kyleborot

Member
Hello all,

I'm trying to create a script in Alibre that uses the surface area of a face in a sheet metal part. I wanted to know if that value is stored anywhere in some sort of log file, or if there's a documented way to use Alibre Script to retrieve and store that information?

Thank you.
 

bolsover

Senior Member
Measurements are stored in the Alibre file. Unfortunately Alibre Script does not work with Sheet metal parts even though there is a AlibreScript.API.Face,getArea() method in Alibre Script.
Oddly, there is no GetArea() method in the corresponding AlibreX API.
What do you actually need to do?
 

kyleborot

Member
Measurements are stored in the Alibre file. Unfortunately Alibre Script does not work with Sheet metal parts even though there is a AlibreScript.API.Face,getArea() method in Alibre Script.
Oddly, there is no GetArea() method in the corresponding AlibreX API.
What do you actually need to do?
Hi there, thanks for your response. I need to update a sheet metal part's global parameters and then log the surface area of the outermost face. The sheet metal part would only be one lofted flange. If I can't get the SA, will GetPart() work on the sheet metal part?
 

bolsover

Senior Member
@kyleborot
Hi,
I did a little testing in AlibreScript in an effort to find out what might be possible there..
The following was just a test script to find out if is possible to open a Sheet Metal Part using AlibreScript:
Python:
import fnmatch
import os
from os.path import expanduser
Win = Windows()
ScriptName = 'Sheet metal part into'
Options = []
Options.append(['Source file', WindowsInputTypes.File, expanduser('~'), 'Choose the sheet metal part to open'])

Values = Win.OptionsDialog(ScriptName, Options, 300)
if Values == None:
  sys.exit()
 
SM = Values[0]

Folder = os.path.dirname(os.path.abspath(SM))
FileName = os.path.basename(SM)

P = Part(Folder, FileName)

The script (which has to be run from a part editor window) will open a .AD_PRT file in the editor but any attempt to open a .AD_SMP file returns an exception.

A little digging into the AlibreScript code reveals this:
C#:
    public Part(string Folder, string Name)
      : this(Folder, Name, false)
    {
    }

    public Part(string Folder, string Name, bool HideEditor)
    {
      if (!Folder.EndsWith("\\"))
        Folder += "\\";
      Name = Path.GetFileNameWithoutExtension(Name);
      string str = Folder + Name + ".AD_PRT";
      this._Part = this.GetOpenedPart(str);
      if (this._Part == null)
      {
        if (!File.Exists(str))
          throw new Exception(string.Format(\u0023cf.\u0023qWb("The file '{0}' cannot be found."), (object) str));
        this._Part = (IADPartSession) Global.Root.OpenFileEx(str, !HideEditor);
      }
      this.GetReferenceGeometry();
    }
In the above code, there is a line to explicitly force the passed file to have the extension .AD_PRT

So it seems like the author really does not want .AD_SMP files opened with the scripting API!

There is some more flexibility if you write a routine using C# but as I noted before, the AlibeX API does not have the getArea() method.
To give you some idea of the data accessible using C#, you might take a look at my UtilitiesForAlibre Add-On. This includes a Property Viewer that allows you to dig into the structure of a loaded file.
You can download the latest release of the Add-on from the resources section:
UtilitiesForAlibre

PropertyViewer.png

I've never really done much with Sheet Metal Parts. If I get chance I'll dig in a little further and try to find out if what you want may be possible.
David
 
Top