Macro FCCircularText
File:Text-x-python Macro FCCircularText |
Description |
---|
This macro create a text around a cylinder. Author: Mario52 |
Author |
Mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
This macro write you text around a cylinder or a portion of the cylinder.
Example
Here 180 degrees rotation
Utilisation
set the following parameters
# configure begin
#################
PolicePath = "C:/Windows/Polices/KLANG.TTF" # path font #chemin de la police
rayon = 10.0 # radius #rayon du cylindre
texte = "FreeCad The Best" # your text #texte a afficher
# PS: one space give an error #un espace donne une erreur ne pas en tenir compte
rotation = 360 # must exceed the number of characters of text
# doit être supérieur au nombre de caracteres du texte
SizeCaractere = 5.0 # size font #hauteur du caractere
#################
# correction section here for radius 10 mm
# section correction ici pour un rayon de 10 mm
correctionAngle = 10.0 #angle correction tangent #angle de correction pour affiner la tangent du a la largeur du caractere
correctionRayon = 0.15 #correct radius #correction du rayon a cause de correctionAngle et suvant la grandeur du caractere
#################
#configure end
- PolicePath = "C:/Windows/Polices/KLANG.TTF"
- your path font
- rayon = 10.0
- radius of cylinder
- rotation = 180
- rotation occupied by text 0 to ... max 360 (must exceed the number of characters of text)
- texte = "FreeCad The Best"
- your text to display (PS: space gives an error not to consider)
- SizeCaractere = 5.0
- size font
- here for radius 10 mm (change to another radius)
- correctionAngle = 10.0
- correction angle of the tangent to narrow the width of the character
- correctionRayon = 0.15
- radius compensation because of correctionAngle and depending on the size of the character
- correctionAngle = 10.0
Script
Macro FCCircularText.FCMacro
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2014 <mario52> *
* *
* This file is a supplement to the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
# FCCircularText.FCMacro
# ver 0.1 20/08/2014
#
#OS: Windows Vista
#Word size: 32-bit
#Version: 0.14.3700 (Git)
#Branch: releases/FreeCAD-0-14
#Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1
#Python version: 2.6.2
#Qt version: 4.5.2
#Coin version: 3.1.0
#SoQt version: 1.4.1
import FreeCAD, FreeCADGui, Draft, Part
import FreeCAD, Part, PartGui, math
from math import sqrt, pi, sin, cos, asin, degrees, radians, tan
points = 0.0
coor_X = 0.0
coor_Y = 0.0
coor_Z = 0.0
vec = 0
rotation = 0
ii = 0
precision = 0.0
correctionAngle = 0.0
correctionRayon = 0.0
# pointColor
red = 1.0 # 1 = 255
green = 0.0 #
blue = 0.0 #
points = []
del points[:]
# configure begin
#################
PolicePath = "C:/Windows/Polices/KLANG.TTF" # path font #chemin de la police
rayon = 10.0 # radius #rayon du cylindre
texte = "FreeCad The Best" # your text #texte a afficher
# PS: one space give an error #un espace donne une erreur ne pas en tenir compte
rotation = 360 # must exceed the number of characters of text
# doit être supérieur au nombre de caracteres du texte
SizeCaractere = 5.0 # size font #hauteur du caractere
#################
# correction section here for radius 10 mm
# section correction ici pour un rayon de 10 mm
correctionAngle = 10.0 #angle correction tangent #angle de correction pour affiner la tangent du a la largeur du caractere
correctionRayon = 0.15 #correct radius #correction du rayon a cause de correctionAngle et suvant la grandeur du caractere
#################
#configure end
vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon + correctionRayon,0.0,0.0)] #
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) # création de la ligne de base
ii = -1
nombre = len(texte)
for i in range(0,360,(rotation/nombre)): # 360 a parametrer
ii += 1
a = FreeCAD.ActiveDocument.Line.Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1),i), App.Vector(0,0,0))
a = ligne.Shape.Edges[0].Vertexes[1] # fin
coor_X = (a.Point.x)
coor_Y = (a.Point.y)
if ii < nombre:
ss=Draft.makeShapeString(String=texte[ii],FontFile=PolicePath,Size=SizeCaractere,Tracking=0)
plm=FreeCAD.Placement()
plm.Base=FreeCAD.Vector(coor_X,coor_Y,coor_Z)
plm = App.Placement(App.Vector(coor_X,coor_Y,coor_Z), App.Rotation(i+90+correctionAngle,0,90), App.Vector(0,0,0)) # pitch,roll...1
ss.Placement=plm
ss.Support=None
points += [FreeCAD.Vector(coor_X,coor_Y,coor_Z)]
Draft.makeBSpline(points,closed=True,face=False,support=None) # makeBSpline
App.ActiveDocument.removeObject(ligne.Name)
## cercle de verification (avec le rayon donne)
## verification circle (with radius gives)
#pl=FreeCAD.Placement()
#pl.Rotation.Q=(0.0,-0.0,-0.0,1.0)
#pl.Base=FreeCAD.Vector(0.0,0.0,0.0)
#Circle = Draft.makeCircle(radius=10.0,placement=pl,face=False,support=None)
#FreeCADGui.getDocument("Sans_nom").getObject("Circle").LineColor = (1.0000000000,0.0000000000,0.0000000000)
#FreeCADGui.ActiveDocument.Circle.LineColor = (1.0000000000,0.0000000000,0.0000000000)
(not fully developed)
Currently:
- ver 0.1
Links
To comment on the Extrude from curved surface of cylinder