What's new

Polygon over 24 sides hangs = must kill Alibre in TaskMngr

DingBEN

Member
Alibre Design Expert V27
WIN 10, DirectX 12
9th gen Intel Core 5 i5-9400F Processor (2b) 64bit/(32bit) - 2.90GHz
Chip type: NVIDIA GeForce GTX 1660 Ti
full hardware specs attached...


All optimizations per the instructions on the Alibre website Performance section.
System was mostly already set correctly, except I had to point the GPU to the \Program Files\alibre.exe in the OS settings.
Note: the GPU is in 32bit mode(in attached), I don't know if I can/should change that?
...is there something in the BIOS that would need optimizing?

First install... just practicing features/sketching figures thus nothing on the screen, one or 2 polygons and a few lines.
Polygon 24 sides - press Apply - all good... but takes 8-15secs to draw the sides-nodes and release operation
I may have succeeded with a 28 or 30 sided attempt, not sure... a 32 froze. I tried many attempts at various settings.
I need a 48... system just freezes, have waited 1 1/2 hour to see if it would eventually complete... each time, I had to kill Alibre in TaskMngr
Played with resolution, DPI... zero improvement.
No other issues of snagging, slowness, delays, hick ups, ...everything responds well.
I can create a circular pattern of 12 count feature, without issue.

Thank you for any help you may provide.
 

Attachments

  • HARDWARE SPECS.txt
    11.8 KB · Views: 5
Last edited:

DingBEN

Member
hmmm... some nice info has come thru since I posted.
I have quickly scanned these posts and see that PYTHON may not be an answer.

I did a quick test (hours)... all I tested is turning Sketch Options off to see what improvement I would get.
OFF = all Sketch Options off,
ON = Default Options ON - there are 9 of them on the ribbon, so the 3 on bottom and the one at 9 o'clock the other at 3
I did not address anything in SETTINGS, left as delivered.

I found that the time results are not altogether exactly consistent, but close enough.
These are the main examples results, I did many more.
16 off = 2.5s
16 on = 1.5s
24 sides off = 1m 18s now 24 has some potential since it is 48/2.
...but I don't think this will pan out as well as using other suggestions that were made.
32 on = 1m 12s ...faster than 24
32 off = 1m 13s ...on of off, no flagrant difference
32 off = 1m 11s
33 off = 46s ...faster than 24, 32!?
33 off = 1m 2s ...faster than 24, 32!?
34 off = 10m 15s 34 is where it starts taking a jump
36 off = 14m 1s
I stopped here because anything above 5 mins, just won't do.
Thus already going to the next step to use some other way.

One interesting thing I snooped upon:
The input box will take huge numbers, do not seem to be a limit in that baby!
BUT,
- type in 720(or use ticker) and the numbers remain black.
- type in 721 + ...hmmm, now red font.
- type in a massive number, it changes it to a somewhat less massive negative red number

It appears this may not be exactly exponential, but a conundrum with floats numbers in the algorithm.
you know an == versus a === and associated rounding!?
or a binary thing, like an (m)alloc that causes things to not fall on mem boundaries.
- could also be the GPU which is optimized for game(though they confirmed my hardware was no issue)

So, I will go play with SETTINGs if anything else can be turned off.
...and soon, fast into the next go-around.
 

stepalibre

Alibre Super User
Interesting discussion - I do use the Polygon tool occasionally to create Hex nuts or Hex head bolts.screws. And I also used it once to model a Penta Bolt.

As for creating a script to create polygons, that would be nice except for the "awkward" way of running scripts. It would seem logical to have a method for adding scripts to the Ribbon or a Toolbar (if that's your mode of working) so all you need to do is switch to the ribbon/toolbar and click on the script icon to run it. It seems to me a bit tedious to run a script -- select the ribbon, click Launch, search for and select the script and finally select Run. And then when you're done with it you have to exit the script mode by selecting Launch again. The Launch icon should change to an Exit or Stop icon once it is selected, much like the icon for the 2d sketch which changes to Deactivate Sketch.
Is there any way to simplify this process and shorten the number of clicks?
+1, This is the only reason why I personally don't utilise scripts in my workflow. Their use is not streamlined into the normal workflow of Alibre enough. Alibre Script started as an Add-on ... and that's how it is still used. I can create my own add-on and add my own toolbar buttons do do specific functions within that add-on, yet you still can't do that for your 'favourite' or 'essential' python scripts!
I totally agree and I am building simplified ways to write addons. Another approach is to have an external console or windows app that run your code. I am currently working on a IronPython 2 and 3 console addon and a Python addon. They can access AlibreScript API from within Alibre. An issue I have is related to how "Alibre Design.exe" handles and loads assemblies. Another issue is that it won't allow me to run code on a background thread the way I normally do. It blocks and/or somehow hijacks the WPF form. This might be related to WPF event system and not Alibre but I'm looking for solutions. In other words I can't run the form modeless. It works but it blocks Alibre Design until you close the console.

If you want to run AlibreScript python code in an addon you need to use IronPython APIs, passing in your python file. This is how I run my AlibreScript scripts written in VS code. I will give examples and more information after I figure out these issues.
 

stepalibre

Alibre Super User
@HaroldL and @simonb65 using the IronPython APIs if you place the code here:


Inisde a command, you can run your AlibreScript python code.

Here is a quick example I have handy in Vb.net:
[YOUR COMMAND]
Dim eng = IronPython.Hosting.Python.CreateEngine()
Dim scope = eng.CreateScope()
Dim filePath = "C:\Users\steph\Desktop\ironpython3alpha\ironpy_test_script.py"
Dim scriptFile = File.ReadAllText("C:\Users\steph\Desktop\ironpython3alpha\ironpy_test_script.py")
eng.Execute(scriptFile,scope)
eng.ExecuteFile(filePath
[YOUR COMMAND]
 

simonb65

Alibre Super User
Inisde a command, you can run your AlibreScript python code.

Here is a quick example I have handy in Vb.net:
[YOUR COMMAND]
Dim eng = IronPython.Hosting.Python.CreateEngine()
Dim scope = eng.CreateScope()
Dim filePath = "C:\Users\steph\Desktop\ironpython3alpha\ironpy_test_script.py"
Dim scriptFile = File.ReadAllText("C:\Users\steph\Desktop\ironpython3alpha\ironpy_test_script.py")
eng.Execute(scriptFile,scope)
eng.ExecuteFile(filePath
[YOUR COMMAND]
Not sure why you want to run a Python script from VB when you can just write all your script in VB? My Add-Ons are written entirely in C#, so no need to wrap one language in another when you can do everything directly in one language via the API, and get more access to API functions than Alibre Script exposes! Your approach just seems overly complicated for the sake of 'bloat' and a 'just because you can'! Just keep it simple, the API doesn't need yet more layers of added complexity. Just my 2c.

As with all programming 'solutions', what is the problem you are actually trying to solve?
 

DingBEN

Member
Hmmm! @stepalibre ! I am salivating now...

I hope my questions make sense, I am swimming in unknown waters.

Though at this point I am not up to snuff to even understand how all the modules you present are even compiled/interpreted, and installed and made to dance...

Is [YOUR COMMAND] blackboxed in Alibre?
How does the VB code run ?

Looks like the code between the [YOUR COMMAND] creates an instance of a Python runtime environment on the fly ?
- don't understand why the scriptfilename.py is in the Path
- does the VB end as shown ? and just a typo for the closing paren?
...and how does the C-sharp module you point to to github come in the game?

Also: Can what you propose create a javascript(Nodejs) engine? is that even an option?
I use VScode Insiders to write HTML, javascript and I use SQLite ...also just starting with Nodejs to connect my data to web pages.
Unlikely, I will jump into such a heavy tool as Visual Studio!
 

DingBEN

Member
Now I see Simon's response, and believe me I am as blind as it gets, but
it looks like the Alibre API includes the VB interpreter(just in time) and the reason
it is configured that way is to call the special IronPython, which Alibre probably does not offer?
Did I make an arse of meself LOL?
 

stepalibre

Alibre Super User
Not sure why you want to run a Python script from VB when you can just write all your script in VB? My Add-Ons are written entirely in C#, so no need to wrap one language in another when you can do everything directly in one language via the API, and get more access to API functions than Alibre Script exposes! Your approach just seems overly complicated for the sake of 'bloat' and a 'just because you can'! Just keep it simple, the API doesn't need yet more layers of added complexity. Just my 2c.

As with all programming 'solutions', what is the problem you are actually trying to solve?
I work with Python in other CAD apps and for other libraries so using Python is second nature. You can replace the VB code with C#, F# or Python. I program in many languages without thinking about it and so for me its all the same. I have solutions that are entirely Python, VB and C#. What is the purpose of AlibreScript? It is an easier API to learn and use than AlibreX. I like AlibreScript and use it alongside my full .Net solutions.
Looks like the code between the [YOUR COMMAND] creates an instance of a Python runtime environment on the fly ?
Yes. That is only example code that could allow you to run your AlibreScript scripts outside of the AlibreScript addon.
My Add-Ons are written entirely in C#, so no need to wrap one language in another when you can do everything directly in one language via the API, and get more access to API functions than Alibre Script exposes!
Yes, but not all users can or want to program in C++, C# and VB. AlibreScript and Python are much easier to learn and use. AlibreScript has helper methods and utilites not included in AlibreX.dll. I don't use one over another, I utilize whichever API has something I need.
Simon you said:
+1, This is the only reason why I personally don't utilise scripts in my workflow. Their use is not streamlined into the normal workflow of Alibre enough. Alibre Script started as an Add-on ... and that's how it is still used. I can create my own add-on and add my own toolbar buttons do do specific functions within that add-on, yet you still can't do that for your 'favourite' or 'essential' python scripts!
My post was giving you, HaroldL and everyone watching an example of how it is possible to call/run AlibreScripts from an addon, that is all. Not suggesting anything only providing a way it can be done. It is just information that might be useful to someone who is considering scripting and addon development. I directed my post towards the two of you because you made the comments.
call the special Ironython, which Alibre robably does not ofrer?
AlibreScript is IronPython2.7 so it is loaded by Alibre automatically.
Not sure why you want to run a Python script from VB when you can just write all your script in VB?
The purpose of AlibreScript is to provide an easier to learn and use API in Python. If you have existing AlibreScript scripts you can run them from your addon. My example code is how the AlibreScript addon works under the hood. A function of IronPython is to be embedded inside .NET programs. I'm using it as intended. https://github.com/IronLanguages/ironpython3#examples The AlibreScript advanced API allow you to run C# code from Python, this is common and how IronPython is supposed to be used.
Your approach just seems overly complicated for the sake of 'bloat' and a 'just because you can'!
We are talking about less than 25 lines of code total not much at all.
Just keep it simple, the API doesn't need yet more layers of added complexity.
IronPython is loaded by Alibre Design.exe, there is not much more complexity added. All the necessary assemblies are available to you.
1699317734315.png
- don't understand why the scriptfilename.py is in the Path
- does the VB end as shown ? and just a typo for the closing paren?
...and how does the C-sharp module you point to to github come in the game?
The code was meant to illustrate the concept and not be runnable code, although it should work as is. Those details aren't important here.
The C# example addon was used to show where the code could be placed. It is the bare minimum addon that is easy to follow and I use it for testing.
Also: Can what you propose create a javascript(Nodejs) engine? is that even an option?
I use VScode Insiders to write HTML, javascript and I use SQLite ...also just starting with Nodejs to connect my data to web pages.
Unlikely, I will jump into such a heavy tool as Visual Studio!
You can save Alibre data to txt, xml, csv, json or a database to load into a webpage.

I generally provide real example code, links and screenshots in my posts, not only to explain but also to show exactly what I'm talking about. Seeing something rather than just reading text on a screen is often more helpful. I hope this is clear. As always I'm not trying to tell anyone what they should do or convince anyone to take any particular path. These are only options that are available and they might be useful to someone even if they aren't active on the forum.
 
Last edited:

bolsover

Senior Member
I agree with earlier observations that the provided polygon tool should just work. However, given the large number of constraints required when working with high side count polygons, the poor performance is unsurprising.

A little digging around the Alibre libraries revealed the following method. Now I don't pretend to fully understand what is going on but a cursory inspection reveals one unused declaration (thankfully not in a loop) that could be removed. I suspect there is further room to improve.

C#:
private BlockPrimitive recordConstrainPolygonFigure(
      /*Parameter with token 08001FF4*/ReferencePointUV centerRefPoint,
      /*Parameter with token 08001FF5*/ReferencePointUV radiusRefPoint,
      /*Parameter with token 08001FF6*/int sides,
      /*Parameter with token 08001FF7*/bool circumscribed,
      /*Parameter with token 08001FF8*/bool display,
      /*Parameter with token 08001FF9*/bool isFixed)
    {
      this.openChangeTransaction();
      PointUV point = centerRefPoint.Point;
      PointUV pointUv = radiusRefPoint.Point;
      AngleUV angleUv1 = AngleUV.TWO_PI.divideBy((double) sides);
      AngleUV.PI.subtract(angleUv1);
      double radius1 = pointUv.distance(point);
      ReferenceAxisUV refFigureB = (ReferenceAxisUV) null;
      BlockPrimitive blockPrimitive1 = this.implementNewCirclePrimitive(centerRefPoint, radius1, false, isFixed, false);
      ReferenceCircleUV referenceFigureLocal1 = (ReferenceCircleUV) blockPrimitive1.PrimaryReferenceFigureLocal;
      if (!circumscribed)
      {
        AngleUV angle = point.findAngle(pointUv);
        AngleUV angleUv2 = angleUv1.divideBy(2.0);
        double tangent = angleUv2.Tangent;   // tangent is unused - this line should be deleted.
        double radius2 = radius1 / angleUv2.Cosine;
        pointUv = point.getRadialPoint(angleUv2.add(angle), radius2);
        radiusRefPoint = this.newReferencePointLocal(pointUv);
        radius1 = pointUv.distance(point);
      }
      AngleUV angle1 = point.findAngle(pointUv);
      PointUV[] pointUvArray = new PointUV[sides];
      ReferencePointUV[] referencePointUvArray = new ReferencePointUV[sides];
      com.objectspace.jgl.Array items = new com.objectspace.jgl.Array(sides);
      int index1 = 0;
      pointUvArray[index1] = pointUv;
      referencePointUvArray[index1] = radiusRefPoint;
      if (circumscribed)
        this.recordConstrainCoincident((ReferenceFigureUV) referenceFigureLocal1, (ReferenceFigureUV) referencePointUvArray[index1]);
      AngleUV angleUv3 = angle1.add(angleUv1);
      for (int index2 = 1; index2 < sides; ++index2)
      {
        pointUvArray[index2] = new PointUV(point.u + angleUv3.Cosine * radius1, point.v + angleUv3.Sine * radius1);
        referencePointUvArray[index2] = this.newReferencePointLocal(pointUvArray[index2]);
        if (circumscribed)
          this.recordConstrainCoincident((ReferenceFigureUV) referenceFigureLocal1, (ReferenceFigureUV) referencePointUvArray[index2]);
        LineUV lineUv = new LineUV(pointUvArray[index2 - 1], pointUvArray[index2]);
        BlockPrimitive blockPrimitive2 = new BlockPrimitive((FigureUV) lineUv, this.HeaderProperties);
        this.recordConstrainLine((Primitive) blockPrimitive2, lineUv, referencePointUvArray[index2 - 1], referencePointUvArray[index2]);
        ReferenceAxisUV referenceFigureLocal2 = (ReferenceAxisUV) blockPrimitive2.PrimaryReferenceFigureLocal;
        if (!circumscribed)
          this.recordConstrainTangent((ReferenceFigureUV) referenceFigureLocal1, (object) null, (ReferenceFigureUV) referenceFigureLocal2, (object) null);
        refFigureB = referenceFigureLocal2;
        this.recordAddPrimitive((Primitive) blockPrimitive2, display, isFixed);
        items.add((object) blockPrimitive2);
        angleUv3 = angleUv3.add(angleUv1);
      }
      int index3 = sides - 1;
      LineUV lineUv1 = new LineUV(pointUvArray[index3], pointUv);
      BlockPrimitive blockPrimitive3 = new BlockPrimitive((FigureUV) lineUv1, this.HeaderProperties);
      this.recordConstrainLine((Primitive) blockPrimitive3, lineUv1, referencePointUvArray[index3], referencePointUvArray[0]);
      ReferenceAxisUV referenceFigureLocal3 = (ReferenceAxisUV) blockPrimitive3.PrimaryReferenceFigureLocal;
      if (!circumscribed)
        this.recordConstrainTangent((ReferenceFigureUV) referenceFigureLocal1, (object) null, (ReferenceFigureUV) referenceFigureLocal3, (object) null);
      if (refFigureB != null)
        this.recordConstrainAngle((ReferenceFigureUV) referenceFigureLocal3, (ReferenceFigureUV) refFigureB, angleUv1, 0);
      this.recordAddPrimitive((Primitive) blockPrimitive3, display, isFixed);
      this.BlockRelationsConsort.addRelations(512, (Sequence) items, (Sequence) new com.objectspace.jgl.Array(), false);
      this.evaluateDefinition();
      this.closeChangeTransaction();
      return blockPrimitive1;
    }

To solve the problem of high side count regular polygons, the equation editor will do the job quite well.
I tested the attached with 500 sides - reasonably quick - just adjust the INSCRIBED_CIRCLE AND SIDE_COUNT values in the equation editor.
 

Attachments

  • RegularPolygon.AD_PRT
    373 KB · Views: 10

Ex Machina

Alibre Super User
This approach vs a code / script approach is likely to provide similar results. The latter is perhaps more flexible.
Actually what David suggests is the exact same as the file I linked earlier along with the video explaining 2 ways to define it. It's not similar to a script. It is how the program was intended to work. It is parametric design.

Scripting is not the Best Practice in the problem discussed in this thread. The approach David and I suggested is the more robust, efficient and parametrically adaptable way to do it.

This has the additional advantage that you can change the number of sides after insertion that even the existing polygon tool cannot achieve.
 

stepalibre

Alibre Super User
Actually what David suggests is the exact same as the file I linked earlier along with the video explaining 2 ways to define it. It's not similar to a script. It is how the program was intended to work. It is parametric design.
I was referring to speed and flexibility of the geometry needed.

Being able to use a combination of techniques to solve a problem is common. I mentioned those other alternatives as being valid in my other posts here. As I stated, I'm not suggesting any approach is better or worse. These are all valid ways to solve this issue, any issue. You can write a program that provides the exact end result. You can use code to create features, update parameters, etc.. You can do anything you want in any combination. It doesn't have to be one or the other. AlibreScript and AlibreX exist for a reason, to allow users to create custom solutions. Parametric/Feature based tools also exist and should be used.
This is not a fight over coding vs using parametric/feature based tools. I don't care what is used, only that a solution is found.
This has the additional advantage that you can change the number of sides after insertion that even the existing polygon tool cannot achieve.
Yes. You can also write a program to do this. Everything has drawbacks it is up to the user which is best for them. I'm not telling anyone what to do. Many ways to do things, this is all fine.
Scripting is not the Best Practice in the problem discussed in this thread. The approach David and I suggested is the more robust, efficient and parametrically adaptable way to do it.
You can use scripting or anything you want. You can make a program that provides similar results. Or you can use existing features in Alibre. I never said scripting is better, the Alibre API is an option like everything else with pros and cons. I'm not here trying to convince anyone to use Alibre Design supported features AlibreScript or AlibreX. My background is CAD development so yes my focus is programming.

Like @DingBEN I don't understand why discussions become so personal and egoistic. I and others here aren't trying to fight over these issues. I only provide options and ideas which are meant to be FYI and not a declaration or a stance that must be accepted. It all depends on the user and the design goals. Other people viewing this post might perfer a code approach for their work and vice versa. You can do whatever you want. Someone providing different approaches and ideas don't discredit or call into question any other approach or idea. I agree that using built-in features with parameters can be better than a custom solution. Programming is also an option, you decide for yourself.
 

JimCad

Senior Member
I had to do it didn't I ?

Tried it at 500 - - - - Almost instant.
Tried it at 1000 - - - - Almost instant.
Tried it at 10000 - - - - Nearly an hour but it didn't crash. :)

I was thinking the same solution but was unsure of the maths.
Maths is not one of my strong points.
Well done to all who contributed to this thread.

Jim
 

Attachments

  • 10 Thousand.png
    10 Thousand.png
    240.3 KB · Views: 21

Ex Machina

Alibre Super User
I had to do it didn't I ?

Tried it at 500 - - - - Almost instant.
Tried it at 1000 - - - - Almost instant.
Tried it at 10000 - - - - Nearly an hour but it didn't crash. :)

I was thinking the same solution but was unsure of the maths.
Maths is not one of my strong points.
Well done to all who contributed to this thread.

Jim
Cool pic, Jim! Thanks!
 

DingBEN

Member
Hmmm! JimCAD, great info!
I lean towards the best solution that would allow me to use this out of the box.
I am glad for all the info that landed in this thread, I learned a lot, a great source of knowledge.

Your hardware specs speak of massive computing power compared to mine.
My investing in the sort of power you have is not possible for me, as of now.
Your numbers are not to be compared, just a no-brainer all out speed!

Your example is opening my eyes... much appreciation to your chiming in.
The solution via the hardware/settings approach is gaining momentum in my taking a direction.

Currently, I have been working on this:
I am battling NVIDIA, as their current SD (Studio Driver) optimized for CAD vs their GRD(Game Ready Driver) optimized for game, are rejected by the WIN10 update... after install the driver version remains the same!@?
Once I get passed that hurdle, if no adequate results, I have to look into:
- at best a Graphics Card with more mem and newer architecture that would improve the performance to a satisfactory level
- as well as at least doubling my mother-board mem.

It is possible that just going to 16Gg on the mother-board may be all I need. ...and that would be the cheap way out!
I have already ordered mem to climb to 32Gg.

Can you(anyone) chime in and suggest a particular Graphics Card and Driver(that my system can handle)?
see my full hardware specs in original post.
 

JimCad

Senior Member
If and when you do decide to up your pc. Cad is only single core so get the fastest single core speed that you can.
I can't remember who it was but someone on here has one of these CPUs:

1699473259107.png



That is one SERIOUSLY fast single core speed and the total speed when hyperthreading is also VERY good.
I can't comment on the graphics card though.
RAM will also help at 32 GB _ I may have 64 GB but have run out a few times and everything grinds to a halt.
There's no easy answer I can give you really except . . . . save up! ;)

Jim
 

bolsover

Senior Member
@DingBEN
Looking over your hardware specs, I think you 'should' be able to run Alibre without any real difficulty that said, I have 64Gb RAM installed and a very modest Nvidia M5000M graphics card. On my Dell laptop, I know from experience that Nvidia graphic drivers are not all created equal!! I don't recall what version but a couple of years back, one diver caused me no end of headaches - random crashes and screen artifacts - not good. I had to roll back to an older driver to get a stable solution. I still use the same graphics card and have since updated driver a few times without problem.
David
 
Top