What's new

Script Release: Fast Select for Assemblies

I know selecting suppressed items did work when I created it originally. I know it doesn't work now in v28. I tried troubleshooting it a couple weeks ago. The parts are found. The problem occurs when selecting them. Even selecting all will have the issue. Best I can guess is Alibre changed something through the different versions and suppressed items can no longer be selected using the API.
 
Let me know if it works the UI is hard to use, no time to fix hidpi.
I knew the functionality works in .NET I'm working on more assembly code for AlibreObjectModel. There is weirdness with how Alibre works. This should be more reliable search approach, over root level Assem.Parts and Assem.SubAssemblies not just RootOcc.Occurrences. This is common in Alibre assembly programming. What I meant by nested assemblies. I was assuming a higher level was the breaking point not 1 or 2 levels. The safer approach is a complete scan of the tree then trace against what actually loaded above the occurrences root. I think there is/are another occurrence collection that has all the items but without live state. Or that's RootOcc.Occurrences.

1776681843861.png
 
I know selecting suppressed items did work when I created it originally. I know it doesn't work now in v28. I tried troubleshooting it a couple weeks ago. The parts are found. The problem occurs when selecting them. Even selecting all will have the issue. Best I can guess is Alibre changed something through the different versions and suppressed items can no longer be selected using the API.
Does it report back correctly which parts are suppressed before trying to select them?

I've been getting incorrect results when trying to update my part weight script to skip suppressed parts. My current work around is to suppress and also hide the part, as checking if it's hidden still works. Have you already reported the bug to Alibre? I will if not.
 
Does it report back correctly which parts are suppressed before trying to select them?

I've been getting incorrect results when trying to update my part weight script to skip suppressed parts. My current work around is to suppress and also hide the part, as checking if it's hidden still works. Have you already reported the bug to Alibre? I will if not.
Did you try my script? If it works, the issues you're having with part weight can be fixed.
 
Did you try my script? If it works, the issues you're having with part weight can be fixed.
Let me know if it works the UI is hard to use, no time to fix hidpi.
I knew the functionality works in .NET I'm working on more assembly code for AlibreObjectModel. There is weirdness with how Alibre works. This should be more reliable search approach, over root level Assem.Parts and Assem.SubAssemblies not just RootOcc.Occurrences. This is common in Alibre assembly programming. What I meant by nested assemblies. I was assuming a higher level was the breaking point not 1 or 2 levels. The safer approach is a complete scan of the tree then trace against what actually loaded above the occurrences root. I think there is/are another occurrence collection that has all the items but without live state. Or that's RootOcc.Occurrences.

View attachment 47051
You're too quick for me! I was responding separately.

My assembly is 3 sub-assemblies w/configurations. So there's no single parts in the top level assembly to break it. Here's what I get running your script:

Loading
Waiting for form...
Form active

================================
Starting selection. Please wait.
Traceback (most recent call last):
File "<string>", line 644, in <module>
File "<string>", line 128, in DoSelect
EnvironmentError: System.Runtime.InteropServices.COMException (0x8000FFFF): Object reference not set to an instance of an object.
at com.alibre.automation.ExceptionMap.handleException(Exception inputException)
at com.alibre.automation.AlibreSession.Select(IObjectCollector pEntities)
at Microsoft.Scripting.Interpreter.ActionCallInstruction`2.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 System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.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)
 
Its running is V28 on my machine. I used Fast Select 1_1.txt - 24.8 KB · Views: 9.

If you download the gist it's - fix.py

1776784793053.png
1776784428232.png
 
It appears to function on my machine.
The approach is more brute force, it may be influenced by assembly load speed, regen, size, etc.
Or something in your assemblies or parts is crashing selection.

1776785960725.png
 
Or the configuration options aren't getting loaded properly. You may need to start at configuration 1 and switch configurations in scripts not manually.

1776786606165.png
 
Adding configuration support to PDM is on my task list, I'll share any insights and solutions as sample code. I haven't started that work yet.
 
@stepalibre Your version of the script works for suppressed if I do it in an assembly that has parts in the top level instead of sub-assemblies. It correctly counts the suppressed parts, but doesn't select them. That's probably what @NateLiquidGravity was talking about before.

I updated my weight update script to use GetMappedOccurrence() instead of GetOccurrence(), and it correctly returns the suppressed status now. I'll update my post later incase anybody else needs it.

Sorry for hi-jacking your post @NateLiquidGravity!
 
doesn't select them.
This appeared to work when I tested a new file with several nested sub-assemblies.
I have build 28228, your signature says 28227
It does work in .NET. Selection is separate from assembly dataflow. I think this is Alibre Script not the AlibreX API or Alibre per se. I understand Alibre Script can use AlibreX there is still a difference that make debugging these kinds of behaviors difficult. You and Nate are probably right Alibre Script isn't working. If it's broke in .NET that's significant.

This is the same kind of issue that I experienced for Area Moments script that was solved in.NET and C++.
 
if I do it in an assembly that has parts in the top level instead of sub-assemblies.
This can be fixed properly. It should work recursively without much effort. Does it work without configurations?

Edit: I'll build a C++ version as another test case. I hope it's only Alibre Script not a more serious issue. Assembly work takes longer than parts. I'll update you in a few weeks.

Edit: I took a quick look at assembly selection in c#. It works recursively at all levels. It would need to be fully tested, the behavior with configurations and all the various combinations and assembly states. I won't cover everything and I'm not sure what all the problems are. I'm working on AlibreObjectModel so this does matter if there are assembly issues. I don't think there are any.
 
Last edited:
I forgot to mention property explorer. I created this to help diagnose issues, state changes and reading values by tree view. You could merge the scripts together for a better understanding.
 
Any additional information and comments I have will be on this page. I may post updates here. Check the link for the latest. I do this kind of work (testing/R&D) during off-hours, between tasks, and on weekends.
 
The problem wasn't in finding the suppressed items. The problem in my testing is that this line would error if some items in the selection set were suppressed. ThisSess.Select(SelectedSet)

Now I was testing with a rather large assembly with subassemblies and possibly configurations as well. When I looked at RootOcc.Occurrences I had expected Alibre API would only hand me occurrences that existed in the current state of the assembly and perhaps that is then the problem. Alibre API is VERY unfriendly.

If I can get this fixed I'll work on the display issue.
 
Yes, we are on the same page. I believe the issues are with Alibre Script selection and component state. I asked if it was nested and to what extent. It's possible to change a property while looping, which is why it matters where the state change is being made. Finding the suppressed items and performing any operation on an item is the same. When at the step where you want to perform an operation if the component is suppressed you may not see it, have access to it or reset the state when leaving the component. It could be a bug. I personally don't trust Alibre Script for this type of task, it should just work. We shouldn't have to fight it.

The approach I would use is:
Figure out all the state changes up-front
Verify
Perform selection in a separate loop/function
Verify
 
I forgot to mention property explorer. I created this to help diagnose issues, state changes and reading values by tree view. You could merge the scripts together for a better understanding.

Yes, we are on the same page. I believe the issues are with Alibre Script selection and component state. I asked if it was nested and to what extent. It's possible to change a property while looping, which is why it matters where the state change is being made. Finding the suppressed items and performing any operation on an item is the same. When at the step where you want to perform an operation if the component is suppressed you may not see it, have access to it or reset the state when leaving the component. It could be a bug. I personally don't trust Alibre Script for this type of task, it should just work. We shouldn't have to fight it.

The approach I would use is:
Figure out all the state changes up-front
Verify
Perform selection in a separate loop/function
Verify

You could use bolsover's property viewer to debug Alibre Script.

1777059808552.png

I use an updated version all the time.

1777059633035.png
 
Is there a way to adopt this into a script that will allow you to slect parts from the assembly and create a new sub assembly from them? I have a situation where a customer has changed what they want in the subassemblies and it basically means I need to start again with them. At the moment I have an assembly file which has 3 sub assemblies in it. It would be great to be able to go through, and copy and paste them or move them or something into a new subassembly. Then delete off the old ones. I suppose the bonus with the assembly I'm working with is that it's imported from another system, and all parts are modelled about an assembly axis, not their own. So when I bring in a part I click all parts to the origin point and they are in the right place.
 
Back
Top