FreeCAD Python
|
Utility functions for theArch Workbench.
This module provides general functions used by Arch tools and utility commands
Functions | |
def | string_replace (text, pattern, replacement) |
def | getStringList (objects) |
def | getDefaultColor (objectType) |
def | addComponents (objectsList, host) |
def | removeComponents (objectsList, host=None) |
def | makeComponent (baseobj=None, name="Component", delete=False) |
def | cloneComponent (obj) |
def | setAsSubcomponent (obj) |
def | copyProperties (obj1, obj2) |
def | splitMesh (obj, mark=True) |
def | makeFace (wires, method=2, cleanup=False) |
def | closeHole (shape) |
def | getCutVolume (cutplane, shapes, clip=False) |
def | projectToVector (shape, vector) |
def | meshToShape (obj, mark=True, fast=True, tol=0.001, flat=False, cut=True) |
def | removeCurves (shape, dae=False, tolerance=5) |
def | removeShape (objs, mark=True) |
def | mergeCells (objectslist) |
def | download (url, force=False) |
def | check (objectslist, includehidden=False) |
def | getHost (obj, strict=True) |
def | pruneIncluded (objectslist, strict=False) |
def | survey (callback=False) |
def | toggleIfcBrepFlag (obj) |
def | makeCompoundFromSelected (objects=None) |
def | cleanArchSplitter (objects=None) |
def | rebuildArchShape (objects=None) |
def | getExtrusionData (shape, sortmethod="area") |
def ArchCommands.addComponents | ( | objectsList, | |
host | |||
) |
addComponents(objectsList,hostObject): adds the given object or the objects from the given list as components to the given host Object. Use this for example to add windows to a wall, or to add walls to a cell or floor.
def ArchCommands.check | ( | objectslist, | |
includehidden = False |
|||
) |
check(objectslist,includehidden=False): checks if the given objects contain only solids
def ArchCommands.cleanArchSplitter | ( | objects = None | ) |
cleanArchSplitter([objects]): removes the splitters from the base shapes of the given Arch objects or selected Arch objects if objects is None
def ArchCommands.cloneComponent | ( | obj | ) |
cloneComponent(obj): Creates a clone of an object as an undefined component
def ArchCommands.closeHole | ( | shape | ) |
closeHole(shape): closes a hole in an open shape
def ArchCommands.copyProperties | ( | obj1, | |
obj2 | |||
) |
copyProperties(obj1,obj2): Copies properties values from obj1 to obj2, when that property exists in both objects
def ArchCommands.download | ( | url, | |
force = False |
|||
) |
download(url,force=False): downloads a file from the given URL and saves it in the macro path. Returns the path to the saved file. If force is True, the file will be downloaded again evn if it already exists.
def ArchCommands.getCutVolume | ( | cutplane, | |
shapes, | |||
clip = False |
|||
) |
getCutVolume(cutplane,shapes,[clip]): returns a cut face and a cut volume from the given shapes and the given cutting plane. If clip is True, the cutvolume will also cut off everything outside the cutplane projection
def ArchCommands.getDefaultColor | ( | objectType | ) |
getDefaultColor(string): returns a color value for the given object type (Wall, Structure, Window, WindowGlass)
def ArchCommands.getExtrusionData | ( | shape, | |
sortmethod = "area" |
|||
) |
getExtrusionData(shape,sortmethod): returns a base face and an extrusion vector if this shape can be described as a perpendicular extrusion, or None if not. sortmethod can be "area" (default) or "z".
def ArchCommands.getHost | ( | obj, | |
strict = True |
|||
) |
getHost(obj,[strict]): returns the host of the current object. If strict is true (default), the host can only be an object of a higher level than the given one, or in other words, if a wall is contained in another wall which is part of a floor, the floor is returned instead of the parent wall
def ArchCommands.getStringList | ( | objects | ) |
getStringList(objects): returns a string defining a list of objects
def ArchCommands.makeComponent | ( | baseobj = None , |
|
name = "Component" , |
|||
delete = False |
|||
) |
makeComponent([baseobj]): creates an undefined, non-parametric Arch component from the given base object
def ArchCommands.makeCompoundFromSelected | ( | objects = None | ) |
makeCompoundFromSelected([objects]): Creates a new compound object from the given subobjects (faces, edges) or from the selection if objects is None
def ArchCommands.makeFace | ( | wires, | |
method = 2 , |
|||
cleanup = False |
|||
) |
makeFace(wires): makes a face from a list of wires, finding which ones are holes
def ArchCommands.mergeCells | ( | objectslist | ) |
mergeCells(objectslist): merges the objects in the given list into one. All objects must be of the same type and based on the Cell object (cells, floors, buildings, or sites).
def ArchCommands.meshToShape | ( | obj, | |
mark = True , |
|||
fast = True , |
|||
tol = 0.001 , |
|||
flat = False , |
|||
cut = True |
|||
) |
meshToShape(object,[mark,fast,tol,flat,cut]): turns a mesh into a shape, joining coplanar facets. If mark is True (default), non-solid objects will be marked in red. Fast uses a faster algorithm by building a shell from the facets then removing splitter, tol is the tolerance used when converting mesh segments to wires, flat will force the wires to be perfectly planar, to be sure they can be turned into faces, but this might leave gaps in the final shell. If cut is true, holes in faces are made by subtraction (default)
def ArchCommands.projectToVector | ( | shape, | |
vector | |||
) |
projectToVector(shape,vector): projects the given shape on the given vector
def ArchCommands.pruneIncluded | ( | objectslist, | |
strict = False |
|||
) |
pruneIncluded(objectslist,[strict]): removes from a list of Arch objects, those that are subcomponents of another shape-based object, leaving only the top-level shapes. If strict is True, the object is removed only if the parent is also part of the selection.
def ArchCommands.rebuildArchShape | ( | objects = None | ) |
rebuildArchShape([objects]): takes the faces from the base shape of the given (or selected if objects is None) Arch objects, and tries to rebuild a valid solid from them.
def ArchCommands.removeComponents | ( | objectsList, | |
host = None |
|||
) |
removeComponents(objectsList,[hostObject]): removes the given component or the components from the given list from their parents. If a host object is specified, this function will try adding the components as holes to the host object instead.
def ArchCommands.removeCurves | ( | shape, | |
dae = False , |
|||
tolerance = 5 |
|||
) |
removeCurves(shape,dae,tolerance=5): replaces curved faces in a shape with faceted segments. If dae is True, DAE triangulation options are used
def ArchCommands.removeShape | ( | objs, | |
mark = True |
|||
) |
removeShape(objs,mark=True): takes an arch object (wall or structure) built on a cubic shape, and removes the inner shape, keeping its length, width and height as parameters. If mark is True, objects that cannot be processed by this function will become red.
def ArchCommands.setAsSubcomponent | ( | obj | ) |
Sets the given object properly to become a subcomponent (addition, subtraction) of an Arch component
def ArchCommands.splitMesh | ( | obj, | |
mark = True |
|||
) |
splitMesh(object,[mark]): splits the given mesh object into separated components. If mark is False, nothing else is done. If True (default), non-manifold components will be painted in red.
def ArchCommands.string_replace | ( | text, | |
pattern, | |||
replacement | |||
) |
if py2 isn't supported anymore calls to this function should be replaced with: `text.replace(pattern, replacement)` for python2 the encoding must be done, as unicode replacement leads to something like this: ``` >>> a = u'abc mm ^3' >>> a.replace(u"^3", u"³") u'abc mm \xc2\xb3' ```
def ArchCommands.survey | ( | callback = False | ) |
survey(): starts survey mode, where you can click edges and faces to get their lengths or area. Clicking on no object (on an empty area) resets the count.
def ArchCommands.toggleIfcBrepFlag | ( | obj | ) |
toggleIfcBrepFlag(obj): toggles the IFC brep flag of the given object, forcing it to be exported as brep geometry or not.