What's new

Custom Alibre File Browser

bolsover

Senior Member
Just wondering if this might be of interest to other Alibre users...
I'm really bad at entering descriptions and part # for my designs and started to wonder if it might be possible to get some help.
This is no more than a bit of casual code tinkering at present - but so far I've managed to create an application window that can show (just description and Par# at present) in a file browser like window:
Screenshot 2022-01-18 140517.jpg
My goal is to enable direct entry of descriptions and Part# in this window and update the Alibre files.

If anyone is interested, I'll happily share the code I have at present once I've done some clean up! and added the appropriate disclaimers.

DB
 

bolsover

Senior Member
No. It is a custom application written in C#. Works by getting information from the Alibre files using the ALIBREX.DLL and API.
The C# code is quite simple but the application uses a third party, free library to generate the initial file tree. On selecting directories (checkbox in image), the application connects to AlibreX and retrieves the custom Alibre data.
I have not yet tried writing back to the Alibre files - but in theory it should be easy enough.
DB
 

bolsover

Senior Member
Hi Stefan
I hadn't seen that thread - looks interesting - but only works one part at a time?
My intention is to make something that will allow user to edit multiple properties in a single place.
One idea is to allow auto part# generation - maybe by providing a seed number and then renumbering all parts in a directory.
Outputting all data fields to a spreadsheet should also be possible.

db
 

bolsover

Senior Member
OK...
So I'm a bit new to C# but I'm making progress with my data browser..
The attached .zip contains a .exe and a .dll
If you want to try out what I have so far, you'll need to extract the files and copy into the Alibre directory containing AlibreX.dll.
On my system this is C:\Program Files\Alibre Design\Program
The program should launch when double clicked or you could create a shortcut - the important thing is that it needs to be able to find the AlibreX.dll. or it will do nothing!

At present, the application can update Description, Part Number and Created Date. and can filter the directory tree for Alibre design files.
I'll be adding edit features for the remaining fields over the next few days (material could be tricky) - but wanted to let people get a preview of the idea.

IMPORTANT - THERE ARE NO GAURANTEES AND YOU TEST AT YOUR OWN RISK

I have tested on my own live data - so far no adverse problems.

Comments would be very welcome.

DB
 

Attachments

  • DataBrowser.zip
    189.2 KB · Views: 8

Cator

Senior Member
Hi bolsover
I just tried it and it works fine also in Alibre V23 with Win 11.
I would like and it would be the best that it had a button inside Alibre like Alibre Script or KeyShot or TracePart ... You would be able to insert it in the Add- On ??
Thanks anyway for your work it's a great start!
 

idslk

Alibre Super User
the important thing is that it needs to be able to find the AlibreX.dll. or it will do nothing!
for AlibreScript i've done this:
Code:
def getalibrepath():
    hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"Software\\Alibre, Inc.\\Alibre Design")
    result = _winreg.QueryValueEx(hKey, "HomeDirectory")
    return result[0]

alibrex = getalibrepath() + 'Program\\AlibreX.dll'

Here i've done something with the material. :)

Regards
Stefan
 

bolsover

Senior Member
Hi bolsover
I just tried it and it works fine also in Alibre V23 with Win 11.
I would like and it would be the best that it had a button inside Alibre like Alibre Script or KeyShot or TracePart ... You would be able to insert it in the Add- On ??
Thanks anyway for your work it's a great start!
Many thanks for the feedback. I'm only testing against V24, Win 11 but From my read of the AlibreX docs, I thought it would be OK against V22 and V23 but not earlier.
Making it an Add-On is certainly possible - but I haven't yet looked at the Add-On code to see how it's done.

DB
 

bolsover

Senior Member
for AlibreScript i've done this:
Code:
def getalibrepath():
    hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"Software\\Alibre, Inc.\\Alibre Design")
    result = _winreg.QueryValueEx(hKey, "HomeDirectory")
    return result[0]

alibrex = getalibrepath() + 'Program\\AlibreX.dll'

Here i've done something with the material. :)

Regards
Stefan
Hi Stefan
Thanks for the feedback...
Nice hint re checking the registry for the path to AlibreX.dll - I'll certainly be doing something similar.
I think I should re-name the app - probably not OK to reference Alibre in the name - copyright and all that.
I've just done a couple of tests with materials - from what I have so far it seems easy enough to retrieve the material library. I just need to create a tree from which the user can select the required item.

Just an idle thought... I might try listing constituent parts under assemblies in the browser tree. It will slow things up but may be worthwhile.
On the topic of speed, I also need to run some of the code in a separate thread. At present, selecting a directory triggers retrieval of all the part data in that directory and sub-directories. I've seen this cause the app to become unresponsive and even show up a black window - not good - I need to fix.

all the best, David
 

bolsover

Senior Member
If you have been following this thread, you'll know that I'm attempting to write a utility that allows for editing of the Alibre Design properties.

Screenshot 2022-02-04 110150.jpg

Retrieval, display and editing, saving of most properties turns out to be relatively simple - just a matter of connecting to Alibre and making the right calls to the methods detailed in the API documentation.

Materials
Retrieval, display and selection of Materials is however a whole different ball game!!

There are a couple of major issues..

The data structures used by Alibre are a bit odd (overly complex in my view) and rather poorly documented in the Alibre API which only mentions a couple of interfaces : IADMaterial and IADMaterials. In reality there are no fewer than 6 interfaces involved: IADMaterial, IADMaterials, IADMaterialLibrary, IADMaterialLibraries, IADMaterialLibraryFolder and IADMaterialLibraryFolders.

I genuinely don't understand why they made it so complicated - but I eventually managed to recreate a view of Material Library structure that matches the one used by Alibre in terms of general appearance.

The next big problem was being able to select a material from the list and update the Alibre design..
The Alibre API for IADDesignProperties exposes methods for updating of a few standard and several extended properties. The properties relating to Material are 'string' based properties and the API provides methods to set these.

Unfortunately, setting the Material design property has to be done by referencing the 'Guid' of the material. The 'Guid' is a a public property of a private field within IADMaterial (Alibre not making this easy!!) Screengrab from my debugger below..

Screenshot 2022-02-04 113002.jpg

The ONLY way I have foulnd to access the 'Guid' is to use reflection to access the private alibreMaterial field and then the Guid property. Now I wouldn't normally try to do this - Alibre may have made the alibreMaterial field private for some good reason. But it does seem odd that they then allow users to update the IADDesignProperties Material property.

Here's the code I'm presently using to access the Guid:

C#:
    public string GetAlibreMaterialGuid(object obj)
    {
        var t = obj.GetType();
        var fieldInfo = t.GetField("alibreMaterial",
            BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
            BindingFlags.Static);
        var alibreMaterial = fieldInfo.GetValue(obj);
        var t2 = alibreMaterial.GetType();
        var propertyInfo2 = t2.GetProperty("Guid",
            BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
            BindingFlags.Static);
        var guid = propertyInfo2.GetValue(alibreMaterial);
        return (string) guid;
    }

I'm sure the above will change - but good for experimants.

I'll be updatingall the code to my github repository in the next day or two..


DB
 

bolsover

Senior Member
All the latest code has been pushed to GitHub
You can compile for yourself or try out the compiled .exe in the attached .zip
To use you have to place DataBrowser.exe and ObjectListView.dll in the Alibre program files directory and run from there.
IMPORTANT - THERE ARE NO GAURANTEES AND YOU TEST AT YOUR OWN RISK
Comments and feedback welcome
Enjoy.
DB
 

Attachments

  • DataBrowser.zip
    194.7 KB · Views: 4

bolsover

Senior Member
Having managed to get infected with Covid, I've found myself with extra time to devote to this small project.

Main - and Only window
Once an Alibre Part/Sheet metal/Assembly file has been selected, any existing Design or extended design parameters will be shown in the browser.
If there are many files in a directory selected, the process of retrieving the Alibre data can take a little while - please be patient!!
Having retrieved the Alibre data you can now edit any of the table cells by double clicking the cell. Only Alibre Part/Sheet metal/Assembly files are editable. Material can only be edited for Alibre Part and Sheet metal files.
You can filter the display to show only Alibre files by checking the 'Filter for Alibre Designs' checkbox

DataBrowserForAlibre.jpg

The columns shown in the browser can be changed by right clicking the table header.
Once you have the desired display, click the 'Save State' button. The column setting is stored in a file %AppData%/Local/DataBrowser/table.settings

DataBrowserColumnControl.jpg

Part Numbering
The Part # column data can be edited like other columns by double clicking and entering the desired number.
Alternatively, if you want to renumber several files, the 'Part No' button will open a dialog that allows you to sequentially number the files.
I've tried to keep this simple with a prefix, number and suffix. The Step controls how the part number is incremented.
Save writes the setting to file %AppData%/Local/DataBrowser/partnumber.settings
Apply writes the number to the Alibre files.
Screen grab before Apply..
DataBrowserPartNumbering1.jpg
Screen Grab after Apply:
DataBrowserPartNumbering2.jpg

Copy to all selected
When checked, this will cause entry in one field to be copied to all selected, same column fields - useful if you want the same keywords or dates in a whole bunch of different files.


Materials
Selection of a new material is done using a custom selection tool:
Note that selecting a material here will overwrite any existing extended design property for Material - Alibre also does this but give you a warning - this application does not give a warning.
DataBrowserMaterial.jpg

Bugs
As with any software, this has bugs and issues. The main issue at present is one of performance - retrieval of Alibre data can be slow and any attempt to interrupt an cause the application to crash.
I'm working on a fix!
Not withstanding the issues, I'm finding it useful - I hope you do also.


Source code
All source code is available from my GitHub repository:
https://github.com/bolsover/DataBrowserForAlibre

Installation
The application MUST be run from the Alibre Install, Program folder - on my PC this is C:\Program Files\Alibre Design\Program.
All you have to do is to copy the two files in the attached DataBrowser.zip to that folder and you can then run the program, create a shortcut etc..
I hope to remove this file location issue in a future release.

Please let me know if you find major problems or if you would like to see enhancements..

Disclaimer - I've tried to keep the utility harmless - but can't be held responsible for any damage it does to your files or sanity. I suggest you test on a couple of non-essential designs before you let loose on production!!

That's all for now,

DB
 

Attachments

  • DataBrowser.zip
    204.8 KB · Views: 9

DavidJ

Administrator
Staff member
DB, I finally got around to trying this. When I follow the tree down to a folder where many of my AD files are, if I click on + in tree to expand the folder, the application just closes.

Is there some limit as to how many levels the tree can have for the application to work? It is working for some other folders....
 

bolsover

Senior Member
Hi David

Thanks for the feedback. There is no limit on the number of folder levels. It's my guess it is failing on some particular file in your directory.
I've not done much more with the app over the last couple of weeks (holiday and head elsewhere..) I did see a the app crash a few times - but usually when I got over eager trying to update files while others were being indexed.
I have however made some updates to the code while attempting to produce an Add-On app. Some of those updates 'may' have fixed the problem you are seeing.
One thing I will be doing for a future version is putting in some error traps and hopefully some user feedback.

If you fancy some debugging yourself, you can always download the source code here...
https://github.com/bolsover/DataBrowserForAlibre

Kind regards, David
 

simonb65

Alibre Super User
Source code compiling is beyond me....

@bolsover (David), it may be worth putting a compiled add-on .dll and associated .adc (plus any images the icon functions) on the github site once you've produced the Add-On as an app.

I have however made some updates to the code while attempting to produce an Add-On app.
If you're having issues, let me know, I've done quite a few bespoke add-ons, so can probably give you some pointers!
 
Top