What's new

Script Release: Assembly Tree V3

NateLiquidGravity

Alibre Super User
Assem.FileName gets a string of the path and filename of the assembly.
I am using a python trick of not passing output variables in the function call but that is pretty standard to do in python. However I'm guessing that the API call is encountering an error and is returning an error code that I'm not checking for. I'll try making something for you to test.
 

DavidJ

Administrator
Staff member
Thanks Nate - I have a working system now - so no rush for further enhancements.

It's already being useful to quickly check GUIDs of parts in assembly, when weird behaviour is reported.
 

BobSchaefer

Senior Member
David and Nate, first, keep in mind I only skimmed the discussion and haven't looked at the script, but from what I have, I might have a thought as to what's causing the issue. David, before you mapped the drive, I take it you were using the double backslash and server name to start your path, is that correct? If so, then it might be the starting double backslash that is causing the issue, as lots of string functions use that as an escape sequence to signify a single backslash.

Again, I'm just guessing as I haven't looked at the code nor do I know if python has the same issue (I assume it might) but its something I've seen in other languages that might cause the issue.
 

DavidJ

Administrator
Staff member
Yes - double backslash. Well that's what it resolves to after browsing to the network to the location. Not sure how to robustly work around that...
 

simonb65

Alibre Super User
Yes - double backslash. Well that's what it resolves to after browsing to the network to the location. Not sure how to robustly work around that...
Before you use the path string returned from the browser, do a string replace "\" with "\\" before passing that to the function. That would make your returned path string "\\Servername\directory\directory\directory\filename.ext" into "\\\\Servername\\directory\\directory\\directory\\filename.ext".
 

DavidJ

Administrator
Staff member
Ah so just add \\ to the front of the string.

But I guess that might break the 'mapped drive' case...

I'm sure there'll be a way! Outside jobs this weekend, unless the weather is bad - in which case I will play further...
 

simonb65

Alibre Super User
Just check if the string starts with "\\" or a letter, then prepend the "\\" as required or just try using ...

literalpath = repr(path)

... to expand and remove the possible interpretation of the escape characters as the path string is passed onwards.
 
Last edited:

idslk

Alibre Super User
Hello David,

what is the result in a "RMB/Constituents" window?
upload_2020-9-25_22-43-20.png
How are the files/paths named there?

what is the printout to the console window if you add the folloing line the V3?

upload_2020-9-25_22-47-21.png

Regards
Stefan
 

DavidJ

Administrator
Staff member
Manually adding "\\" + into the call has allowed the script to run for network folders.

I suspect I've missed a line to update, as the GUID value isn't actually reported at the moment. Hopefully on the right track...

Must get back to replacing the garden fence.
 

NateLiquidGravity

Alibre Super User
I think you guys are jumping to conclusions. The path should already be valid as a string because it already exists as a string from AlibreScript. My script isn't creating the path.

Secondly (but unrelated to the error at issue as the string already exists) if you wanted to store a string in Python without it interpreting anything in the string you just prefix with an r in front like this:
FileString = r"\\Servername\directory\directory\directory\filename.ext"
This tells Python it is a raw string and absolutely no escape characters are used.
 

simonb65

Alibre Super User
The path should already be valid as a string because it already exists as a string from AlibreScript. My script isn't creating the path.
The problem isn't your script, but the way the path is handled within the Alibre functions. Hence the debug code that @idslk suggests. It seems to me like traditional 'mapped' filenames, i.e. "Z:\directory\directory\directory\filename.ext" are handled (interpreted!) within Alibre functions differently to "\\servername\directory\directory\directory\filename.ext", irrespective of how define them as a local 'literal' string or not, as in this case the string isn't being defined, but returned from one function and then passed to another function. The latter case obviously needs some 'correction/intervention' before it's passed on!

BTW: repr(...) is the runtime assignment as opposed to the compile time r".." assignment of a literal.
 

NateLiquidGravity

Alibre Super User
If David runs the script to output html with one of the settings for filenames he will see them output and can even try clicking them to see if they open correctly.
 

DavidJ

Administrator
Staff member
I do know that the GUID functions in the API were written during the Geomagic days - i.e. were written by a different team than both older historic stuff and any recent API updates. I believe they were written with one specific integration in mind (TeamPlatform), so they may not have been designed to work generically.

It would obviously be nice if this script behaved nicely for any file path - but for now I have ways to get it to work by using the mapped drive. I'll slowly work through as much of the suggested stuff as I can understand....
 

DavidJ

Administrator
Staff member
Using repr(...) in the script does result in production of a tree for network stored assembly/parts - but the GUID value is not populated in the output - see partial image of output.
Empty GUIDs.jpg
Tends to make me think there might be a limitation in the API function... could well be that it expects a local drive. I'll ask Alibre's CTO to take a look at the code, after the current activity on v22 dies down. A fix isn't essential, but it would be good to understand any limitations.
 

DavidJ

Administrator
Staff member
Stefan,

When I insert that print command I get (when assembly is in network folder).

\\JUPP-SERVER/Users/David Jupp/Business/My Documents/Clients/Alibre, LLC/27424/Test of boolean issue/New Assembly (1).AD_ASM
Traceback (most recent call last):
File "<string>", line 474, in <module>
File "<string>", line 141, in AssemblyTreeHTML
File "<string>", line 165, in AssemblyTreeHTMLGen
ValueError: Length cannot be less than zero.
Parameter name: length



With same assembly opened via mapped drive
Z:/27424/Test of boolean issue/New Assembly (1).AD_ASM

Tree GUID work.jpg
 
Last edited:
Top