Repeating pattern on a cylinder

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!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Repeating pattern on a cylinder

Post by DeepSOIC »

sakudoo wrote:Or would you see another way to construct a much more versatile line?
You can use Draft stuff on that surface the sketch is mapped to. The requirement is that the segments must match up well when arrayed, otherwise the array will not fuse them into a continuous wiggly ring
sakudoo
Posts: 3
Joined: Thu Oct 15, 2015 8:24 am

Re: Repeating pattern on a cylinder

Post by sakudoo »

Thanks a lot again for the very helpful hints.

It turned out however that I did not point out an essential requirement of my task: The wiggly line (going around the cylinder) shall have some undercuts, hence the proposed extrusion of the loft (along the cylinder axis) will intersect with itself and yield an incorrect result. For illustration see my little picture attached.

Is there a way in FreeCAD to cut a solid in two pars using an arbitrary surface? (In this way, one could use the loft surface to cut the cylinder into two parts and discard one of them.) - Sorry to bother you again!
Attachments
Pattern with undercut2.jpg
Pattern with undercut2.jpg (118.2 KiB) Viewed 2089 times
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Repeating pattern on a cylinder

Post by quick61 »

Are you talking about a shape like this?
LikeThis1.png
LikeThis1.png (29.59 KiB) Viewed 2078 times
Loft won't work as you know because of self intersects, so I used a bit different workflow including ShapeBuilder to get the final shape.
CrownCommon.fcstd
(39.6 KiB) Downloaded 49 times
Mark

OS: Kubuntu 14.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.5747 (Git)
Build type: Release
Branch: master
Hash: 2e6c94fc8e2641e26611632d95e6a28a1618aa89
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17-dev
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Repeating pattern on a cylinder

Post by DeepSOIC »

sakudoo wrote:Is there a way in FreeCAD to cut a solid in two pars using an arbitrary surface?
Sort of YES. One way pointed by Mark. There is another, probably less messy, but involves python console.
Type:

Code: Select all

Part.show(App.ActiveDocument.Loft.Shape.copy().makeHalfSpace(App.Vector(0,0,0)))
You will get a magic shape that looks like a copy of the loft, but it can be used in Boolean operations Cut and Common.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Repeating pattern on a cylinder

Post by DeepSOIC »

I think we need a gui tool for making half-spaces. It is so easy. I think I will bother to make it and pull request.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Repeating pattern on a cylinder

Post by DeepSOIC »

Oh no! It can be done with Gui! There is a command "Convert to solid", which, when applied to Loft, seems to produce the same result.
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: Repeating pattern on a cylinder

Post by mario52 »

hi
may be
Mills00.png
Mills00.png (74.66 KiB) Viewed 2048 times
Mills01.FCStd
(158.3 KiB) Downloaded 51 times
Python best friend FreeCAD

Code: Select all

import FreeCAD, Draft, Part
from FreeCAD import Base

__title__   = "Macro_Mills"
__author__  = "Mario52"
__date__    = "17/10/2015"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.01"

#################### 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)
offset   = 20  # 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,((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 = ligne.Shape.Edges[0].Vertexes[1]                                       # fin de la ligne 1 de base principale
        coor_X = (a.Point.x)
        coor_Y = (a.Point.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 = ligne2.Shape.Edges[0].Vertexes[1]                                     # fin de la ligne 2 de base principale
        coor_X2 = (aa.Point.x)
        coor_Y2 = (aa.Point.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))]
    ##
    ressort = Draft.makeWire(a,closed=True,face=True)                      # makeWire
    ##
#    ressort = Draft.makeBSpline(a,closed=True,face=True)                  # makeBSpline
    ##
    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()
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Repeating pattern on a cylinder

Post by jmaustpc »

DeepSOIC wrote:I think we need a gui tool for making half-spaces. It is so easy. I think I will bother to make it and pull request.
Hi DeepSOIC
Yorik started what became a four page topic on creating a HalfSpace tool a while ago...I found a the topic, here is the link.
viewtopic.php?f=8&t=6371

Jim
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Repeating pattern on a cylinder

Post by DeepSOIC »

Thanks for the link, Jim! I had some diagonal reading, and it gave me a sence of a discussion that ended with no decision.
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: Repeating pattern on a cylinder

Post by chrisb »

mario52 wrote:Python best friend FreeCAD
Mario, have you ever modeled something in FreeCAD using the GUI without writing a special macro :) ?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply