Macro Line Length/cs: Difference between revisions

From FreeCAD Documentation
No edit summary
mNo edit summary
Line 1: Line 1:
{{Macro/cs|Icon=Text-x-python|Name=Macro Line_Length|Name/cs=Macro Line Length|Description=Vytvoří přímku danou argumenty jež jsou souřadnice XYZ, délka a úhel.|Author=mario52|Version=1.0}}
{{Macro/cs|Icon=Text-x-python|Name=Macro Line_Length|Name/cs=Macro Line Length|Description=Vytvoří přímku danou argumenty jež jsou souřadnice XYZ, délka a úhel.|Author=mario52|Version=02.00|Date=08/08/2014}}


==Desciption==
This small macro create a line giving as an argument the XYZ coordinates, length, and angle
This small macro create a line giving as an argument the XYZ coordinates, length, and angle


==Use==
===Use===
Can be used from the Freecad macro editor.
Can be used from the Freecad macro editor.


Je-li toto makro zkopírováno do konzoly Pythonu, můžete je použít takto:
Je-li toto makro zkopírováno do konzoly Pythonu, můžete je použít takto:


<syntaxhighlight>
{{Code|code=
>>> line_length(x1 = 0, y1 = 0, z1 = 0, length = 10, angle = 45)
>>> line_length(x1 = 0, y1 = 0, z1 = 0, length = 10, angle = 45)
</syntaxhighlight>
}}


nebo jinak
nebo jinak


<syntaxhighlight>
{{Code|code=
>>> line_length(x1 = 10, y1 = 10, z1 = 0, length = 50)
>>> line_length(x1 = 10, y1 = 10, z1 = 0, length = 50)


>>> line_length(length = 50, angle = 45)
>>> line_length(length = 50, angle = 45)
</syntaxhighlight>
}}


defaultní hodnoty jsou : x1 = 0, y1 = 0, z1 = 0, length(délka) = 10, angle(úhel) = 0
defaultní hodnoty jsou : x1 = 0, y1 = 0, z1 = 0, length(délka) = 10, angle(úhel) = 0


==Script==
===Script===
Macro Line_Length.py
Macro Line_Length.py


<syntaxhighlight>
{{Code|code=
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# créer une ligne avec une coordonnée une longueur et un angle sur le plan X Y
# créer une ligne avec une coordonnée une longueur et un angle sur le plan X Y
Line 48: Line 47:
line_length(x1, y1, z1, length, angle)
line_length(x1, y1, z1, length, angle)


</syntaxhighlight>
}}
{{clear}}
{{clear}}
<languages/>
<languages/>

Revision as of 10:33, 26 September 2017

File:Text-x-python Macro Line_Length

Popis
Vytvoří přímku danou argumenty jež jsou souřadnice XYZ, délka a úhel.

Version macro : 02.00
Date last modification : 08/08/2014
Autor: mario52
Autor
mario52
Download
None
Odkazy
Verze
02.00
Datum poslední úpravy
08/08/2014
Verze FreeCAD
None
Výchozí zástupce
None
Viz též
None

This small macro create a line giving as an argument the XYZ coordinates, length, and angle

Use

Can be used from the Freecad macro editor.

Je-li toto makro zkopírováno do konzoly Pythonu, můžete je použít takto:

>>> line_length(x1 = 0, y1 = 0, z1 = 0, length = 10, angle = 45)

nebo jinak

>>> line_length(x1 = 10, y1 = 10, z1 = 0, length = 50)

>>> line_length(length = 50, angle = 45)

defaultní hodnoty jsou : x1 = 0, y1 = 0, z1 = 0, length(délka) = 10, angle(úhel) = 0

Script

Macro Line_Length.py

# -*- coding: utf-8 -*-
# créer une ligne avec une coordonnée une longueur et un angle sur le plan X Y
# create line with coordinate length and angle to plane X Y
import FreeCAD, FreeCADGui, Draft
from math import cos, sin, radians
#from FreeCAD import Base
 
def line_length(x1 = 0.0, y1 = 0.0, z1 = 0.0, length = 10.0, angle = 0.0):
    x2 = x1 + (length * cos(radians(angle)))
    y2 = y1 + (length * sin(radians(angle)))
    z2 = z1 #+ ()
    Draft.makeWire([FreeCAD.Vector(x1,y1,z1),FreeCAD.Vector(x2,y2,z2)])
 
x1 = 0.0          # Edit coordinate x1 origin
y1 = 0.0          # Edit coordinate y1 origin
z1 = 0.0          # Edit coordinate z1 origin
length = 50.0       # Edit length
angle  = 45.0       # Edit angle plane XY
 
line_length(x1, y1, z1, length, angle)
Other languages: