Rainure cranté sur un disque

Forum destiné aux questions et discussions en français
Forum rules
Règles du forum et informations utiles.

VEUILLEZ LIRE CECI AVANT DE DEMANDER DE L'AIDE
User avatar
Jimidi
Posts: 512
Joined: Wed Jul 26, 2017 3:53 pm

Re: Rainure cranté sur un disque

Postby Jimidi » Sat Mar 21, 2020 11:13 am

Bonjour,


Pour témoignage : avec ma version 0.19, pour 36 occurrences de répétition circulaire, afin de ne pas avoir de plantage il m'a fallu arrondir les dimensions théoriques des bases de triangles (obtenues sur esquisse dédiée) au millième inférieur.
Là, pas de souci :


hirth_JMD explications.jpg
hirth_JMD explications.jpg (469.29 KiB) Viewed 35 times

... le fichier :

hirth_JMD.FCStd
(383.84 KiB) Not downloaded yet

Salutations, Jean-Michel
mario52
Posts: 2849
Joined: Wed May 16, 2012 2:13 pm

Re: Rainure cranté sur un disque

Postby mario52 » Sat Mar 21, 2020 11:46 am

Bonjour

j'avais fais un macro (crée les faces) (ici corrigée pour FC 0.18/19) pour Repeating pattern on a cylinder ici une autre discussion polar detent to lock rotation at discrete values aka Hirth Joint avec un lien intéressant pour calculer les angles Standard Hirth coupling calcul

Code: Select all

import FreeCAD, Draft, Part
from FreeCAD import Base
#
#https://forum.freecadweb.org/viewtopic.php?f=3&t=12835&p=102957#p102957
#https://forum.freecadweb.org/viewtopic.php?f=3&t=36179
#http://thmq.mysteria.cz/hirth/
#
__title__   = "Macro_Mills"
__author__  = "Mario52"
__date__    = "19/03/2020"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02"

#################### create new document if not existe ##################
doc = FreeCAD.ActiveDocument                                         ####
if doc == None:                                                      ####
    doc = FreeCAD.newDocument()                                      ####
#########################################################################

############## Modify here ####################
nombre            = 36   # number objects for 1 turn must sous multiple of 360 ex 20, 10, 36 ...
rayon             = 20   # radius (axe to object)
hauteur           = 5    # heigth header (tooth)
hauteurAxeCentral = 0    # heigth central axis
offset            = 0    # offset decallage (- direction left, + directon rigth, 0 center )
###############################################

vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon,0.0,0.0)]    # vector for line directrice
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None)   # creation de la ligne de base 1 principale
ligne2 = Draft.makeWire(vecligne,closed=False,face=False,support=None)  # creation de la ligne de base 2 (retrait)

coor_X  = 0.0
coor_Y  = 0.0
coor_Z  = 0.0
coor_X2 = 0.0
coor_Y2 = 0.0
coor_Z2 = 0.0

comptF = pas = 0
points = []
del points[:]
comP   = []
del comP[:]

for i in range(0,360,(int(360/nombre))):                                              # boucle principale 0 to 360 degrees
        FreeCAD.ActiveDocument.getObject(ligne.Name).Placement=App.Placement(App.Vector(0.0,0.0,coor_Z), App.Rotation(App.Vector(0,0,1),i), App.Vector(0,0,0))
        a = FreeCAD.activeDocument().getObject(ligne.Name).End                      # fin de la ligne 1 de base principale
        coor_X = (a.x)
        coor_Y = (a.y)
#        p1 = Draft.makePoint(coor_X,coor_Y,coor_Z)                                # create point green (line 1)
#        FreeCADGui.ActiveDocument.getObject(p1.Name).PointColor = (0.0,1.0,0.0)   # create point green (line 1)

        FreeCAD.ActiveDocument.getObject(ligne2.Name).Placement=App.Placement(App.Vector(0.0,0.0,coor_Z2), App.Rotation(App.Vector(0,0,1),(i-offset)), App.Vector(0,0,0))
        aa = FreeCAD.activeDocument().getObject(ligne2.Name).End                    # fin de la ligne 2 de base principale
        coor_X2 = (aa.x)
        coor_Y2 = (aa.y)
#        p2 = Draft.makePoint(coor_X2,coor_Y2,coor_Z2)                             # create point red (line 2)
#        FreeCADGui.ActiveDocument.getObject(p2.Name).PointColor = (1.0,0.0,0.0)   # create point red (line 2)

        if pas == 1:
            coor_Z = hauteur
            points += [FreeCAD.Vector(coor_X,coor_Y,coor_Z)]
            pas = 0
        else:
            coor_Z2 = 0
            points += [FreeCAD.Vector(coor_X2,coor_Y2,coor_Z2)]
            pas = 1

        ###################
#        points += [points[-1]]                                            # create eventail (bonus)
        ###################
#        shell = Draft.makeWire(points,closed=True,face=True)              # create a shell  (bonus)
#        shell.Label = "Shell"
####################

#contour = Draft.makeWire(points,closed=True,face=True)                    # create contour makeWire
#contour.Label = "ContourWire"

####################

#contour = Draft.makeBSpline(points,closed=True,face=True)                 # create contour makeBSpline
#contour.Label = "ContourBSpline"

########################### section create object face #####################
a    = []
del a[:]

coor_X = coor_Y = coor_Z = 0.0

for i in range(nombre):                                                    # create faces
    a += [(points[i])]
    try:
        a += [(points[i+1])]
    except Exception:
        a += [(points[0])]
    a += [(FreeCAD.Vector(coor_X,coor_Y,coor_Z + hauteurAxeCentral))]
    ##
    ressort = Draft.makeWire(a,closed=True,face=True)                      # makeWire
    ##
#    ressort = Draft.makeBSpline(a,closed=True,face=True)                  # makeBSpline
    ##
    FreeCADGui.activeDocument().getObject(ressort.Name).DisplayMode = u"Flat Lines"
    ressort.MakeFace = True
    del a[:]

App.ActiveDocument.removeObject(ligne.Name)                                # remove ligne de base directrice 1
App.ActiveDocument.removeObject(ligne2.Name)                               # remove ligne de base directrice 2
FreeCAD.ActiveDocument.recompute()

Image

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.