ArchCommands Namespace Reference

Utility functions for the Arch Workbench. More...

Classes

class  SurveyTaskPanel
 

Functions

def addComponents (objectsList, host)
 
def check (objectslist, includehidden=False)
 
def cleanArchSplitter (objects=None)
 
def cloneComponent (obj)
 
def closeHole (shape)
 
def copyProperties (obj1, obj2)
 
def download (url, force=False)
 
def getAllChildren (objectlist)
 
def getCutVolume (cutplane, shapes, clip=False)
 
def getDefaultColor (objectType)
 
def getExtrusionData (shape, sortmethod="area")
 
def getHost (obj, strict=True)
 
def getShapeFromMesh (mesh, fast=True, tolerance=0.001, flat=False, cut=True)
 
def getStringList (objects)
 
def makeComponent (baseobj=None, name="Component", delete=False)
 
def makeCompoundFromSelected (objects=None)
 
def makeFace (wires, method=2, cleanup=False)
 
def makeIfcSpreadsheet (archobj=None)
 
def mergeCells (objectslist)
 
def meshToShape (obj, mark=True, fast=True, tol=0.001, flat=False, cut=True)
 
def printMessage (message)
 
def printWarning (message)
 
def projectToVector (shape, vector)
 
def pruneIncluded (objectslist, strict=False)
 
def rebuildArchShape (objects=None)
 
def removeComponents (objectsList, host=None)
 
def removeCurves (shape, dae=False, tolerance=5)
 
def removeShape (objs, mark=True)
 
def setAsSubcomponent (obj)
 
def splitMesh (obj, mark=True)
 
def string_replace (text, pattern, replacement)
 
def survey (callback=False)
 
def toggleIfcBrepFlag (obj)
 

Detailed Description

Utility functions for the Arch Workbench.

This module provides general functions used by Arch tools and utility commands

Function Documentation

◆ addComponents()

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.

Referenced by importIFClegacy.read().

◆ check()

def ArchCommands.check (   objectslist,
  includehidden = False 
)
check(objectslist,includehidden=False): checks if the given objects contain only solids

Referenced by printWarning().

◆ cleanArchSplitter()

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

◆ cloneComponent()

def ArchCommands.cloneComponent (   obj)
cloneComponent(obj): Creates a clone of an object as an undefined component

References makeComponent().

◆ closeHole()

def ArchCommands.closeHole (   shape)
closeHole(shape): closes a hole in an open shape

Referenced by printWarning().

◆ copyProperties()

def ArchCommands.copyProperties (   obj1,
  obj2 
)
copyProperties(obj1,obj2): Copies properties values from obj1 to obj2,
when that property exists in both objects

◆ download()

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.

Referenced by importDXF.errorDXFLib(), and importIFClegacy.getSchema().

◆ getAllChildren()

def ArchCommands.getAllChildren (   objectlist)

◆ getCutVolume()

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

References DraftVecUtils.project(), and DraftVecUtils.scaleTo().

Referenced by ArchVRM.Renderer.cut(), ArchCutPlane.cutComponentwithPlane(), ArchSectionPlane.getCutShapes(), ArchPipe.makePipeConnector(), and ArchSpace.removeSpaceBoundaries().

◆ getDefaultColor()

def ArchCommands.getDefaultColor (   objectType)

◆ getExtrusionData()

def ArchCommands.getExtrusionData (   shape,
  sortmethod = "area" 
)
If a shape has been extruded, returns the base face, and extrusion vector.

Determines if a shape appears to have been extruded from some base face, and
extruded at the normal from that base face. IE: it looks like a cuboid.
https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid

If this is the case, returns what appears to be the base face, and the vector
used to make that extrusion.

The base face is determined based on the sortmethod parameter, which can either
be:

"area" = Of the faces with the smallest area, the one with the lowest z coordinate.
"z" = The face with the lowest z coordinate.
a 3D vector = the face which center is closest to the given 3D point

Parameters
----------
shape: <Part.Shape>
    Shape to examine.
sortmethod: {"area", "z"}
    Which sorting algorithm to use to determine the base face.

Returns
-------
Extrusion data: list
    Two item list containing the base face, and the vector used to create the
    extrusion. In that order.
Failure: None
    Returns None if the object does not appear to be an extrusion.

Referenced by ArchComponent.Component.getExtrusionData().

◆ getHost()

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

◆ getShapeFromMesh()

def ArchCommands.getShapeFromMesh (   mesh,
  fast = True,
  tolerance = 0.001,
  flat = False,
  cut = True 
)

◆ getStringList()

def ArchCommands.getStringList (   objects)
getStringList(objects): returns a string defining a list
of objects

Referenced by ArchStructure.placeAlongEdge().

◆ makeComponent()

def ArchCommands.makeComponent (   baseobj = None,
  name = "Component",
  delete = False 
)
makeComponent([baseobj]): creates an undefined, non-parametric Arch
component from the given base object

Referenced by cloneComponent().

◆ makeCompoundFromSelected()

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

◆ makeFace()

def ArchCommands.makeFace (   wires,
  method = 2,
  cleanup = False 
)
makeFace(wires): makes a face from a list of wires, finding which ones are holes

Referenced by ArchPanel.CommandPanelSheet.Activated(), getShapeFromMesh(), and ArchVRM.Renderer.projectFace().

◆ makeIfcSpreadsheet()

def ArchCommands.makeIfcSpreadsheet (   archobj = None)

◆ mergeCells()

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).

Referenced by printWarning().

◆ meshToShape()

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)

References getShapeFromMesh().

Referenced by printWarning().

◆ printMessage()

def ArchCommands.printMessage (   message)

◆ printWarning()

◆ projectToVector()

def ArchCommands.projectToVector (   shape,
  vector 
)
projectToVector(shape,vector): projects the given shape on the given
vector

References DraftVecUtils.project(), and DraftVecUtils.scaleTo().

Referenced by ArchRebar.makeRebar().

◆ pruneIncluded()

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.

◆ rebuildArchShape()

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.

◆ removeComponents()

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.

References setAsSubcomponent().

Referenced by ArchCutPlane.cutComponentwithPlane(), and importIFClegacy.read().

◆ removeCurves()

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

References getShapeFromMesh(), and importDAE.triangulate().

◆ removeShape()

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.

References ArchStructure.makeStructure(), and ArchWall.makeWall().

Referenced by printWarning().

◆ setAsSubcomponent()

def ArchCommands.setAsSubcomponent (   obj)
Sets the given object properly to become a subcomponent (addition, subtraction)
of an Arch component

References getDefaultColor().

Referenced by removeComponents(), and ArchComponent.removeFromComponent().

◆ splitMesh()

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.

Referenced by printWarning().

◆ string_replace()

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'
```

Referenced by ArchCommands.SurveyTaskPanel.clipArea(), and survey().

◆ survey()

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.

References string_replace(), and draftutils.utils.utf8_decode().

◆ toggleIfcBrepFlag()

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.

Referenced by printWarning().