1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script Release: Assembly Tree V3

Discussion in 'Alibre Script' started by NateLiqGrav, Dec 20, 2018.

  1. NateLiqGrav

    NateLiqGrav Alibre Super User

    Assembly Tree V3 Updated 9/23/2020
    by NateLiqGrav


    Fixed issues with special characters in file names.
    Added GUID option.

    Assembly Tree V2 Updated 12/31/2018
    by NateLiqGrav
    Had 25 downloads when replaced by V3

    Now with a user interface (based on albie0803's) and rainbow bubbles.
    Also now works with unsaved files and creates a red alert when discovered (as seen in image)
    Red_Alert.png

    Assembly Tree V1 12/20/2018
    by NateLiqGrav

    List all the parts in an assembly and it's sub-assemblies. See the results in the photo below. The green lines are where my mouse was hovering. Those are links to open the assembly/parts.

    Use AssemblyTree to print in the console
    Use AssemblyTreeHTML to make and load an HTML file with tree and links to files
    Use AssemblyTreeHTML2 to make and load an HTML file with bubbles and links to files
    Pass it an assembly object.
    AssemblyTreeHTML and AssemblyTreeHTML2 need the location and name to save the html file as.
    verbose is optional. 0 = off, 1 = filenames, 2 = filenames and parameters
    DO NOT USE tabstep or string_stream they are for internal use of the function only.

    Example usage at the bottom of the script.


    Assembly Tree.png
     

    Attached Files:

    Last edited: Sep 23, 2020
  2. idslk

    idslk Alibre Super User

    Hello Nate,

    cool work!
    May you can add a File input box for the file location stuff

    Regards
    Stefan
     
  3. NateLiqGrav

    NateLiqGrav Alibre Super User

    Yeah I can do but won't be able until after the holidays.
     
    idslk likes this.
  4. DavidJ

    DavidJ Alibre Super User Staff Member

    If - like me - your 'My documents' lives in a non-standard location, be particularly careful when editing the file locations in the script. If you just edit the user name, you may get failures. Took a while for me to realise why it wasn't working...
     
  5. albie0803

    albie0803 Alibre Super User

    Will this work with vault locations?

    All the HTML commands throw the following error:

    Code:
    System.ArgumentException: Illegal characters in path.
       at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
       at System.IO.Path.GetFileName(String path)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at Microsoft.Scripting.PlatformAdaptationLayer.OpenInputFileStream(String path, FileMode mode, FileAccess access, FileShare share)
       at IronPython.Runtime.PythonFile.__init__(CodeContext context, String name, String mode, Int32 buffering)
       at IronPython.Modules.Builtin.open(CodeContext context, String name, String mode, Int32 buffering)
       at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.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.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
       at IronPython.Compiler.PythonCallTargets.OriginalCallTarget3(PythonFunction function, Object arg0, Object arg1, Object arg2)
       at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
       at Microsoft.Scripting.Interpreter.DynamicInstruction`6.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.#ijb(Object #9A)
    
    The filepath is correct, I copied it directly from the folder window bar to be sure.

    AssemblyTreeHTML(Assem,"C:\Users\allan\Documents\Alibre Script Library\Tree\savehtml1.html", 0)

    Edit: This worked, changing the \ to /
    AssemblyTreeHTML(Assem,"C:/Users/allan/Documents/Alibre Script Library/Tree/savehtml1.html", 0)
     
    Last edited: Dec 28, 2018
  6. albie0803

    albie0803 Alibre Super User

    The function is nice but the progressive darker background only works so far.

    upload_2018-12-29_14-16-34.png
     
  7. albie0803

    albie0803 Alibre Super User

    I've had a bit of fun and added input boxes and a folder path.

    Use at your own risk!:)

    Thanks so much Nate for the work you have done on this, it is way above my coding level. I'm sure it will be well appreciated by the community.
     

    Attached Files:

    Last edited: Dec 29, 2018
  8. DavidJ

    DavidJ Alibre Super User Staff Member

    Seems to work OK with Vault for me.
     
  9. NateLiqGrav

    NateLiqGrav Alibre Super User

    Yeah I figured that may happen to someone. I was thinking about altering it so that it goes through a rainbow instead of grayscale thereby giving it many more steps. Alternatively wrap the text and make the background of the text constant.
     
  10. NateLiqGrav

    NateLiqGrav Alibre Super User

    Bumping to alert to V2 update in original post.

    Your welcome. I used your user interface as a jumping off point for V2. Thanks.

    I've detailed some tricks in there that you might like.
     
  11. albie0803

    albie0803 Alibre Super User

    Finally able to check this out (back at work, my home comp died) and I like the changes you have made.
     
    NateLiqGrav likes this.
  12. DavidJ

    DavidJ Alibre Super User Staff Member

    Hi Nate,

    I asked another user to run your Assembly Tree v2 script as we were trying to capture the assembly structure and paths through a series of actions to gather evidence of a very obscure issue.

    Though your script runs fine for me, it errored out for the other user with

    File "<string>", line 275, in AssemblyTreeHTMLGen2

    File "C:\PROGRAM FILES\ALIBRE DESIGN\PROGRAM\ADDONS\ALIBRESCRIPT\PythonLib\urllib.py", line 1250, in quote

    File "C:\PROGRAM FILES\ALIBRE DESIGN\PROGRAM\ADDONS\ALIBRESCRIPT\PythonLib\nturl2path.py", line 65, in pathname2url

    KeyError: ⅛


    Does that suggest anything in particular to you? The assembly is quite complex, is there some limits to how deep sub-assemblies can go before the script has issues?? Or is it just a character in a name that the script doesn't like?
     
  13. idslk

    idslk Alibre Super User

    Hello David,

    where has the other user installed alibre? Standard drive and folder? If not...

    Regards
    Stefan
     
  14. DavidJ

    DavidJ Alibre Super User Staff Member

    Stefan, it's a 'plain vanilla' install of AD. Default directory.

    I can imagine that fraction characters from part names might cause problems when handling HTML. Pity, as Nate's script is a great way to capture a record of the structure - just not in this particular case it seems.
     
  15. idslk

    idslk Alibre Super User

    Checked it. If the 1/8 is part of the filename, it will cause the error. Such characters have to be "recoded" with some extra lines of script...
    Regards
    Stefan
     
    simonb65 likes this.
  16. DavidJ

    DavidJ Alibre Super User Staff Member

    At least that explains the symptoms. I'll have to find an alternative approach.
     
  17. DavidJ

    DavidJ Alibre Super User Staff Member

    I'm not missing a similar script somewhere that wouldn't get 'confused' by the fraction characters.....? presumably something that didn't use a web page as the output.

    I don't seem to remember anything like that...
     
  18. idslk

    idslk Alibre Super User

    Hello David,

    how should the result-(file?)look like and what will you do with it?

    Regards
    Stefan
     
  19. DavidJ

    DavidJ Alibre Super User Staff Member

    Stefan - it's not too critical exactly what it looks like. The need is to

    1. Make the full assembly structure clear.
    2. Show paths for all files related to the assembly.

    It is primarily to look for changes after user has made edits / saved - some weird things have been reported, and we need to gather evidence. So I'd want to compare 2 or more listings, and hone in on any differences. So any output that makes the comparison simpler is good.

    A bonus (but not essential), would be to also capture the GUID of the files - that would capture if any 'Save As' operations had gone on.

    I'm comfortable with spreadsheet, text file, etc.
     
  20. NateLiqGrav

    NateLiqGrav Alibre Super User

    I think I fixed it. Give this a try. If it works I will update the first post.

    Edit: Moved file download see first post.
     
    Last edited: Sep 23, 2020
    idslk likes this.

Share This Page