Draft API/ru: Difference between revisions

From FreeCAD Documentation
m (template fr)
(Updating to match new version of source page)
Line 1: Line 1:
These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported.
Эти функции являеются частью модуля Эскизов(Чертежного) и могут быть использованы в сценариях и макросах или в интепритаторе python, как только будет импортирован модуль Draft.


Example:
Пример:
<syntaxhighlight>
import FreeCAD
import FreeCAD
from Draft import *
from Draft import *
Line 7: Line 8:
mydistance = FreeCAD.Vector(2,2,0)
mydistance = FreeCAD.Vector(2,2,0)
move(myrect,mydistance)
move(myrect,mydistance)
</syntaxhighlight>




{{APIFunction|cut|FreeCAD.Object, FreeCAD.Object|Возвращает "Вырезанный" объект состоящий из различий двух данных объектов. Оригинальные объекты скрываются.|Вновь созданный объект}}
{{APIFunction|cut|FreeCAD.Object, FreeCAD.Object|Returns a cut object made from the difference of the 2 given objects. The original objects get hidden.|The newly created object}}
{{APIFunction|extrude|FreeCAD.Object, Vector|Extrudes the given object in the direction given by the vector. The original object gets hidden.|The newly created object}}
{{APIFunction|formatObject|FreeCAD.Object, [FreeCAD.Object]|This function applies to the given target object the current properties set on the Draft toolbar (line color and line width), or copies the properties of a second object if provided. It also places the object in construction group if the construction button is pressed.|Nothing}}
{{APIFunction|fuse|FreeCAD.Object, FreeCAD.Object|Returns an object made from the union of the 2 given objects. If the objects are coplanar, a special Draft Wire is used, otherwise the final object is a standard Part fuse.|The newly created object}}
{{APIFunction|getDraftPath|[string]|Returns the user or system path where the Draft module is running from. If a subpath or a filename is supplied, the full path to the subpath inside the Draft module is returned.|A file path}}
{{APIFunction|getGroupContents|list|Scans recursively the given list for groups. If groups are encountered, their contents are appended to the list.|A list of FreeCAD Objects}}
{{APIFunction|getRealName|string|Strips the trailing numbers from an object name.|The stripped object name}}
{{APIFunction|getSelection| |Returns the current FreeCAD selection.|The current FreeCAD selection.}}
{{APIFunction|makeCircle|radius, [placement], [facemode], [startangle], [endangle]|Creates a circle object with given radius. If a placement is given, it is used. If facemode is False, the circle is shown as a wireframe, otherwise as a face. If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.|The newly created object.}}
{{APIFunction|makeDimension|Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector]|Creates a Dimension object measuring distance between first and second vectors, with the dimension line passign through the third vector if provided. The current line width and color from the Draft toolbar will be used. Instead of 2 vectors, you can also pass a FreeCAD object, and two integers (and optionally a vector where the dimension line must pass). In that case, the dimension will be associated with the object, and measure two of its vertices, indicated by the two given indice numbers.|The newly created object.}}
{{APIFunction|makeLine|Vector, Vector|Creates a line between the two given vectors. The current line width and color from the Draft toolbar will be used.|The newly created object.}}
{{APIFunction|makeRectangle|length, width, [placement], [facemode]|Creates a Rectangle object with length in X direction and height in Y direction. If a placement is given, it is used. If facemode is False, the rectangle is shown as a wireframe, otherwise as a face. The current line width and color from the Draft toolbar will be used.|The newly created object.}}
{{APIFunction|makeText|string or list, [Vector], [screenmode])|Creates a Text object, at the given point if a vector is provided, containing the string or the strings given in the list, one string by line. The current color from the Draft toolbar and the text height and font specified in preferences are used. If screenmode is True, the text always faces the view direction, otherwise it lies on the XY plane.|The newly created object.}}
{{APIFunction|makeWire|list or Part.Wire, [closed], [placement], [facemode]|Creates a DWire object from the given list of vectors or from the given Wire. If closed is True or if first and last points are identical, the wire is closed. If facemode is True (and wire is closed), the wire will appear filled. The current line width and color from the Draft toolbar will be used.|A new Draft DWire (not a Part Wire).}}
{{APIFunction|move|FreeCAD.Object or list, Vector, [copymode])|Moves the given object or the objects contained in the given list in the direction and distance indicated by the given vector. If copymode is True, the actual objects are not moved, but copies are created instead.|The object(s) (or their copies if copymode was True).}}
{{APIFunction|precision| |Returns the precision value from Draft user settings.|An integer.}}
{{APIFunction|rotate|FreeCAD.Object or list, angle, [center], [axis] ,[copymode]|Rotates the given object or the objects contained in the given list with the given angle around the given center if provided, using axis as a rotation axis. If axis is omitted, the rotation will be around the vertical Z axis. If copymode is True, the actual objects are not moved, but copies are created instead.|The objects (or their copies).}}
{{APIFunction|scale|FreeCAD.Object or list, vector, [center], [copymode]|Scales the given object or the objects contained in the given list with a scale factors defined by the given vector (in X, Y and Z directions) around the given center if provided. If copymode is True, the actual objects are not moved, but copies are created instead.|The objects (or their copies).}}
{{APIFunction|select|FreeCAD.Object|Deselects everything and selects only the passed object|Nothing.}}
{{APIFunction|shapify|FreeCAD.Object|Transforms a parametric shape object into non-parametric.|The new object.}}
{{APIFunction|draftify|FreeCAD.Object or list|Turns the given object or each object of the given list into Draft parametric wires.|Nothing.}}
{{APIFunction|getSVG|FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)]|Creates a SVG representation of the given object. The linemodifier attribute is a scale factor (in percents) for line width, and textmodifier for text size. You can also optionally provide a tuple of vectors to define a projection plane, otherwise the geometry will be projected on the XY plane.|a string containing a SVG representation of the given object.}}


{{APIFunction|extrude|FreeCAD.Object, Vector|Вытягивает данный объект в направлении определяемым вектором. Оригинальные объекты скрываются. |Вновь созданный объект}}


[[Category:API]]
{{APIFunction|formatObject|FreeCAD.Object, [FreeCAD.Object]|Это функция применяет на данном объекте текушме настройки Чертежной панели(набора инструментов) (цвет и ширину линий), или копирует свойства второго объекта , если он указан. Она также помещает объект в группу построений если нажата кнопка построений(кнопка совок - чертежной панели).|Ничего}}
[[Category:Poweruser Documentation]]


{{clear}}
{{APIFunction|fuse|FreeCAD.Object, FreeCAD.Object|Возвращает объект получившийся объединением двух указанных объектов. Если объекты лежат в одной плоскости, используется специальный объект Ломаная Прямая(Draft Wire), в противном случае конечный объект является стандартным слиянием деталей.|Вновь созданный объект}}
<languages/>

{{APIFunction|getDraftPath|[string]Возвращает системный или пользовательский путь откуда запущен Draft(Эскизный) модуль. Если указано подпуть(!) или имя файла вернется строка содержащая полный путь вместе с подпутем(!) внутри папки Draft модуля.|Путь к файлу}}

{{APIFunction|getGroupContents|list|Рекурсивно сканирует указанный список групп. Если встречаются группы их содержание добавляется в список.|Список объектов FreeCAD}}

{{APIFunction|getRealName|string|Убирает номер на который оканчивается объект.|Обрезаное имя объекта}}

{{APIFunction|getSelection| |Возвращает текущее выделение FreeCAD.|Текущее выделение FreeCAD.}}

{{APIFunction|makeCircle|radius, [placement], [facemode], [startangle], [endangle]|Создает объект - кружок с указанным радиусом. Если положение указано, оно используется. Если facemode установлен как False, окружность отображается как каркас(окружность), в противно случае как грань. Если начальный И конечный угол указаны (в градусах), они используются, и объект выглядит как дуга.|Вновь созданный объект.}}

{{APIFunction|makeDimension|Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector]|Создает Размерную выноску объект измереяет расстояние между первым и вторым векторами, с размерной линеей проходящей через третий вектор, если он указан. Будут использованы текущая длина и цвет линии из Эскизной панели инструментов. Вместо двух векторов, вы также можете указать объект FreeCAD, и два числа (и опционально вектор через который будет проходить размерная линия). В этом случае, размерная линия будет связана с объектом, и измерит расстояние между двумя вершинами заданными числами.|Вновь созданный объект.}}

{{APIFunction|makeLine|Vector, Vector|Создает линию между двумя заданными векторами. Будут использованы текущая длина и цвет линии из Эскизной панели инструментов.|Вновь созданный объект.}}

{{APIFunction|makeRectangle|length, width, [placement], [facemode]|Создает объект прямоугольник с длинной вдоль направления оси Х и высотой в направлении оси Y. Если положение указано, оно используется. Если facemode установлен как False, прямоугольник отображается как каркас(прямоугольник), в противно случае как грань. Будут использованы текущая длина и цвет линии из Эскизной панели инструментов.|Вновь созданный объект.}}

{{APIFunction|makeText|string or list, [Vector], [screenmode])|Создает тестовый объект в данной точке если задан вектор, содержит строку или строки приведенные в списке, одна строка на линии. Используются текущий цвет из Эскизной панели инструментов , высота текста и шрифт указываются в Настройка. Если screenmode установлен в True, текст всегда расположен в направлении вида(плоскость в которой находится текст), в противном случае он расположен в плоскости XY.|Вновь созданный объект.}}

{{APIFunction|makeWire|list or Part.Wire, [closed], [placement], [facemode]|Создает Ломанную прямую по заданному списку векторов или из заданной Ломанной прямой. Если closed установлен в True или если первая и последняя точки совпадают , ломанная прямая является замкнутой. Если facemode установлен True (и ломанная прямая закнута), замкнута кривая будет заполнена. Будут использованы текущая длина и цвет линии из Эскизной панели инструментов.|Вновь созданный объект.}}

{{APIFunction|move|FreeCAD.Object or list, Vector, [copymode])|Перемещает заданный объект или объекты содержащиеся в заданном списке в направлении и на растояние определяемые вектором. Если copymode установлен как True, подлинные объекты не перемещаются, вместо этого создаются копии.|Объект(ы) (или их копии, если copymode установлен True).}}

{{APIFunction|precision| | Возвращает точное значение Эскизных настроек пользователя.| Число.}}

{{APIFunction|rotate|FreeCAD.Object or list, angle, [center], [axis] ,[copymode]|Попорачивает заданный объект или объекты содержащиеся в заданном списке на заданный угол вокруг заданного центра если он указан, использует ось как ось поворота. Если ось не указана, вращение будет происходить вокруг вертикальной оси Z. Если copymode установлен как True, подлинные объекты не перемещаются, вместо этого создаются копии.|Объекты (или их копии).}}

{{APIFunction|scale|FreeCAD.Object or list, vector, [center], [copymode]|Масштабирует указанный объект или объекты содержащиеся в заданном списке, с масштабным фактором определяемым по заданому вектору (в X, Y и Z направлениях) вокруг указанного центра если есть. Если copymode установлен как True, подлинные объекты не перемещаются, вместо этого создаются копии.|Объекты (или их копии).}}

{{APIFunction|select|FreeCAD.Object|Снимает выбор со всего остального и выбирает только переданый объект| Ничего.}}

{{APIFunction|shapify|FreeCAD.Object|Превращает параметрическую объект-форму в непараметрическую.|Новый объект.}}

{{APIFunction|draftify|FreeCAD.Object or list|Включает заданный объект, или каждый объект из списка в Эскизную параметрическую кривую.|Ничего.}}

{{APIFunction|getSVG|FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)]|Создает SVG предствление указанного объекта. Параметр linemodifier это масштабный фактор(в прцентах)для ширины линииfor line width, и textmodifier для рахзмера текста. Вы также можете дополнительно задать набор векторов определяющих плоскость проекции, в противном случае геометрия будет спроецирована на плоскость XY.|строка содержащая SVG изображение заданного объекта.}}


[[Category:API/ru]]

{{languages/ru | {{en|Draft API}} {{es|Draft API/es}} {{fr|Draft API/fr}} {{se|Draft API/se}}}}

[[Category:Poweruser Documentation/ru]]

Revision as of 21:39, 5 December 2014

These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported.

Example:

 import FreeCAD
 from Draft import *
 myrect = makeRectangle(4,3)
 mydistance = FreeCAD.Vector(2,2,0)
 move(myrect,mydistance)


cut(FreeCAD.Object, FreeCAD.Object)

Description: Returns a cut object made from the difference of the 2 given objects. The original objects get hidden.

Returns: The newly created object

extrude(FreeCAD.Object, Vector)

Description: Extrudes the given object in the direction given by the vector. The original object gets hidden.

Returns: The newly created object

formatObject(FreeCAD.Object, [FreeCAD.Object])

Description: This function applies to the given target object the current properties set on the Draft toolbar (line color and line width), or copies the properties of a second object if provided. It also places the object in construction group if the construction button is pressed.

Returns: Nothing

fuse(FreeCAD.Object, FreeCAD.Object)

Description: Returns an object made from the union of the 2 given objects. If the objects are coplanar, a special Draft Wire is used, otherwise the final object is a standard Part fuse.

Returns: The newly created object

getDraftPath([string])

Description: Returns the user or system path where the Draft module is running from. If a subpath or a filename is supplied, the full path to the subpath inside the Draft module is returned.

Returns: A file path

getGroupContents(list)

Description: Scans recursively the given list for groups. If groups are encountered, their contents are appended to the list.

Returns: A list of FreeCAD Objects

getRealName(string)

Description: Strips the trailing numbers from an object name.

Returns: The stripped object name

getSelection( )

Description: Returns the current FreeCAD selection.

Returns: The current FreeCAD selection.

makeCircle(radius, [placement], [facemode], [startangle], [endangle])

Description: Creates a circle object with given radius. If a placement is given, it is used. If facemode is False, the circle is shown as a wireframe, otherwise as a face. If startangle AND endangle are given (in degrees), they are used and the object appears as an arc.

Returns: The newly created object.

makeDimension(Vector, Vector, [Vector] or FreeCAD.Object, int, int, [Vector])

Description: Creates a Dimension object measuring distance between first and second vectors, with the dimension line passign through the third vector if provided. The current line width and color from the Draft toolbar will be used. Instead of 2 vectors, you can also pass a FreeCAD object, and two integers (and optionally a vector where the dimension line must pass). In that case, the dimension will be associated with the object, and measure two of its vertices, indicated by the two given indice numbers.

Returns: The newly created object.

makeLine(Vector, Vector)

Description: Creates a line between the two given vectors. The current line width and color from the Draft toolbar will be used.

Returns: The newly created object.

makeRectangle(length, width, [placement], [facemode])

Description: Creates a Rectangle object with length in X direction and height in Y direction. If a placement is given, it is used. If facemode is False, the rectangle is shown as a wireframe, otherwise as a face. The current line width and color from the Draft toolbar will be used.

Returns: The newly created object.

makeText(string or list, [Vector], [screenmode]))

Description: Creates a Text object, at the given point if a vector is provided, containing the string or the strings given in the list, one string by line. The current color from the Draft toolbar and the text height and font specified in preferences are used. If screenmode is True, the text always faces the view direction, otherwise it lies on the XY plane.

Returns: The newly created object.

makeWire(list or Part.Wire, [closed], [placement], [facemode])

Description: Creates a DWire object from the given list of vectors or from the given Wire. If closed is True or if first and last points are identical, the wire is closed. If facemode is True (and wire is closed), the wire will appear filled. The current line width and color from the Draft toolbar will be used.

Returns: A new Draft DWire (not a Part Wire).

move(FreeCAD.Object or list, Vector, [copymode]))

Description: Moves the given object or the objects contained in the given list in the direction and distance indicated by the given vector. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The object(s) (or their copies if copymode was True).

precision( )

Description: Returns the precision value from Draft user settings.

Returns: An integer.

rotate(FreeCAD.Object or list, angle, [center], [axis] ,[copymode])

Description: Rotates the given object or the objects contained in the given list with the given angle around the given center if provided, using axis as a rotation axis. If axis is omitted, the rotation will be around the vertical Z axis. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The objects (or their copies).

scale(FreeCAD.Object or list, vector, [center], [copymode])

Description: Scales the given object or the objects contained in the given list with a scale factors defined by the given vector (in X, Y and Z directions) around the given center if provided. If copymode is True, the actual objects are not moved, but copies are created instead.

Returns: The objects (or their copies).

select(FreeCAD.Object)

Description: Deselects everything and selects only the passed object

Returns: Nothing.

shapify(FreeCAD.Object)

Description: Transforms a parametric shape object into non-parametric.

Returns: The new object.

draftify(FreeCAD.Object or list)

Description: Turns the given object or each object of the given list into Draft parametric wires.

Returns: Nothing.

getSVG(FreeCAD.Object, [linemodifier], [textmodifier], [(u,v)])

Description: Creates a SVG representation of the given object. The linemodifier attribute is a scale factor (in percents) for line width, and textmodifier for text size. You can also optionally provide a tuple of vectors to define a projection plane, otherwise the geometry will be projected on the XY plane.

Returns: a string containing a SVG representation of the given object.