Number of specific piece of polar array as expression

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
unelsson
Posts: 11
Joined: Mon Jun 24, 2019 11:57 am

Number of specific piece of polar array as expression

Post by unelsson »

I'm trying to model a cycloidal gear reducer, and I need to be able to model a cycloidal disk.
https://en.wikipedia.org/wiki/Cycloidal_drive

The edge of cycloidal disk can be generated by rolling a secondary circle around a primary circle, and tracking an edge point of the secondary circle as it rolls. This should be doable with a sketch using expressions. I can generate multiple instances of the sketch with a polar array, but each piece in a polar array should calculate a point with an expression, based on which piece of polar array it is.

https://imgur.com/a/xPfxeGB

Can I use the number of specific polar array as an expression? If I have a Number P = 63, then each piece of this array would have a specific value from 1 to 63, and I could use a variable e.g. numberOfCurrentPolarArray to calculate parts of the sketch.. Is this possible?

A workaround would be to know the current angle from X/Y/Z axis.
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Number of specific piece of polar array as expression

Post by bejant »

unelsson wrote: Sat Sep 21, 2019 10:40 pm Can I use the number of specific polar array as an expression?
Sure (I'm guessing you're using a Draft WB > Array):
20190921a.png
20190921a.png (11.3 KiB) Viewed 1681 times
unelsson
Posts: 11
Joined: Mon Jun 24, 2019 11:57 am

Re: Number of specific piece of polar array as expression

Post by unelsson »

Using Array.NumberPolar gives me the amount of polar arrays. I'd need a specific number of individual polar array. Lets say I have NumberPolar = 3 and I have a length constraint based on "f = currentpolar * 3mm". want the following results per piece of array:

Results should be:
Array piece 1, constraint (length): 3mm
Array piece 2, constraint (length): 6mm
Array piece 3, constraint (length): 9mm

Using f = Array.NumberPolar * 3mm would result in 9mm for each, which is not desired for this application.
unelsson
Posts: 11
Joined: Mon Jun 24, 2019 11:57 am

Re: Number of specific piece of polar array as expression

Post by unelsson »

Here is a sample image of something I'd like to achieve...
https://imgur.com/a/z625MoF

It's made of 45 sketches, each has an angle value, and the other values are calculated based on this.

Trying to achieve something like this...
https://www.tec-science.com/mechanical- ... idal-disc/

and this...
https://www.youtube.com/watch?v=guvatctnjww
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Number of specific piece of polar array as expression

Post by Syres »

unelsson wrote: Sun Sep 22, 2019 10:07 pm Trying to achieve something like this...
https://www.tec-science.com/mechanical- ... idal-disc/
Firstly if the following macro is of use then no credit should come in my direction as the base script came from this topic https://forum.freecadweb.org/viewtopic.php?t=33239

1) Copy the script below and save as a FCMacro file in your macro folder
2) In an existing file or new file change to the Sketcher Wb and create a new sketch in XY plane
3) Execute the new macro file

If it produces something like what you require then obviously you will need to adjust the parameters at the top of the file to suit your requirements.

Code: Select all

LargeRadius = 180.0
SmallRadius = 20.0
nbPas = 120
excentrique = 6.0
EpiCycloidAngle = 9.5
# Large line length= sum of the radiuses
ActiveSketch.addGeometry(Part.LineSegment(App.Vector(10,23,0),App.Vector(27.354679,55.016010,0)),False)
ActiveSketch.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) 
c=ActiveSketch.addConstraint(Sketcher.Constraint('Distance',0,LargeRadius+SmallRadius))
ActiveSketch.setVirtualSpace(c, True) 
La=ActiveSketch.addConstraint(Sketcher.Constraint('Angle',-1,1,0,1,2*3.141592653589793*EpiCycloidAngle/360.0))
ActiveSketch.setVirtualSpace(La, True) 
#ActiveSketch.setDatum(La,App.Units.Quantity('0.000000 deg'))

# arc de cercle small radius
ActiveSketch.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(25,31,0),App.Vector(0,0,1),12),-2,0.4),False)
c=ActiveSketch.addConstraint(Sketcher.Constraint('PointOnObject',1,1,0))  # start of the Arc on the large line
ActiveSketch.setVirtualSpace(c, True) 
ActiveSketch.addConstraint(Sketcher.Constraint('Coincident',1,3,0,2)) #center at end of the large line
c=ActiveSketch.addConstraint(Sketcher.Constraint('Radius',1,SmallRadius))
ActiveSketch.setVirtualSpace(c, True) 
 
#  Small line
ActiveSketch.addGeometry(Part.LineSegment(App.Vector(26,35,0),App.Vector(34,38,0)),False)
ActiveSketch.addConstraint(Sketcher.Constraint('Coincident',0,2,2,1)) #start at the end of the large line
c=ActiveSketch.addConstraint(Sketcher.Constraint('Distance',2,excentrique))
ActiveSketch.setVirtualSpace(c, True)
c=App.ActiveDocument.Sketch.addConstraint(Sketcher.Constraint('PointOnObject',1,2,2))
ActiveSketch.setVirtualSpace(c, True)
Sa=ActiveSketch.addConstraint(Sketcher.Constraint('Angle',0,2,2,1,0)) #creer contrainte a 0 (radian))
ActiveSketch.setVirtualSpace(Sa, True)          # make the angle constraint invisible to improve drawing understanding  

n=0
Sv= ActiveSketch.Geometry[2].EndPoint
Lad = (360.000000/nbPas)
Sad = Lad * (LargeRadius/SmallRadius)
if True:
  while n < nbPas :
    n += 1
    App.ActiveDocument.Sketch.setDatum(La,App.Units.Quantity(str(Lad*n+EpiCycloidAngle) + ' deg'))
    App.ActiveDocument.Sketch.setDatum(Sa,App.Units.Quantity(str(Sad*n) + ' deg'))
    Ev= App.ActiveDocument.Sketch.Geometry[2].EndPoint
    App.ActiveDocument.Sketch.addGeometry(Part.LineSegment(Sv,Ev),False)
    Sv=Ev
    
    #clean up of the geometries used to buid the epicycloid
  App.ActiveDocument.Sketch.delGeometry(2)
  App.ActiveDocument.Sketch.delGeometry(1)
  App.ActiveDocument.Sketch.delGeometry(0)
Only tested on Windows 0.18.3 and above builds.
unelsson
Posts: 11
Joined: Mon Jun 24, 2019 11:57 am

Re: Number of specific piece of polar array as expression

Post by unelsson »

Wow! Thanks. It's a good start.

Currently failing with an error (on Manjaro Linux):

Code: Select all

ViewProviderSketch::setEdit: visibility automation failed with an error: 
Traceback (most recent call last):
  File "<string>", line 2, in <module>
<class 'TypeError'>: 'module' object is not callable
Syres
Veteran
Posts: 2902
Joined: Thu Aug 09, 2018 11:14 am

Re: Number of specific piece of polar array as expression

Post by Syres »

Works fine using 0.19pre Appimage if that's any use:

OS: Linux Mint 19.1 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18260 (Git) AppImage
Build type: Release
Branch: master
Hash: dbf0644b60c35273525985fa13859ad39b0c10df
Python version: 3.7.3
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
unelsson
Posts: 11
Joined: Mon Jun 24, 2019 11:57 am

Re: Number of specific piece of polar array as expression

Post by unelsson »

In 0.18.3 Appimage it also does seem to work. Something strange with my build probably. Thanks a lot!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Number of specific piece of polar array as expression

Post by DeepSOIC »

unelsson wrote: Mon Sep 23, 2019 10:54 am In 0.18.3 Appimage it also does seem to work. Something strange with my build probably. Thanks a lot!
Clean build may help.

If it doesn't. Can you check if there is TempoVis.py file in <wherever_freecad_builds_into>/Mod/Show? If there are both TempoVis.py and mTempoVis.py, delete the one without the m prefix, and test. In theory, the presense of (old) TempoVis.py shouldn't cause trouble, but maybe it does.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Number of specific piece of polar array as expression

Post by DeepSOIC »

unelsson wrote: Sat Sep 21, 2019 10:40 pmThe edge of cycloidal disk can be generated by rolling a secondary circle around a primary circle, and tracking an edge point of the secondary circle as it rolls. This should be doable with a sketch using expressions. I can generate multiple instances of the sketch with a polar array, but each piece in a polar array should calculate a point with an expression, based on which piece of polar array it is.
It is NOT doable within FreeCAD. But it is doable in Lattice2, using a tool named "ParaSeries", that can use one sketch and compute the results by varying a constraint for example.

This tutorial should help you get familiar with ParaSeries: https://github.com/DeepSOIC/Lattice2/wi ... t-Tutorial
The problem solved by the tutorial is quite different to yours, but I hope you can extrapolate.

Also, it may be more easy to use clever geometric construction to make an approximation of the shape with a few segments of a circle. Like I did to make a tractrix shape in sketcher very very long ago: https://forum.freecadweb.org/viewtopic.php?t=7822
Post Reply