OpenSCADUtils Namespace Reference

Classes

class  OpenSCADError
 

Functions

def angneg (d)
 
def applyPlacement (shape)
 
def call_openscad_with_pipes (input_filename, output_filename, output_extension, keep_name)
 
def callopenscad (inputfilename, outputfilename=None, outputext='csg', keepname=False)
 
def callopenscadmeshstring (scadstr)
 
def callopenscadstring (scadstr, outputext='csg')
 
def comparerotations (r1, r2)
 
def decomposerotoinversion (m, precision=4)
 
def detsubmatrix (s)
 
def fcsubmatrix (m)
 
def findbestmatchingrotation (r1)
 
def getopenscadexe (osfilename=None)
 
def getopenscadversion (osfilename=None)
 
def isorthogonal (submatrix, precision=4)
 
def isrotoinversionpython (submat, precision=4)
 
def isspecialorthogonal (mat, precision=4)
 
def isspecialorthogonalpython (submat, precision=4)
 
def meshopinline (opname, iterable1)
 
def meshoponobjs (opname, inobjs)
 
def meshoptempfile (opname, iterable1)
 
def mirror2mat (nv, bv)
 
def mirrormesh (msh, vec)
 
def multiplymat (l, r)
 
def newtempfilename ()
 
def process2D_ObjectsViaOpenSCAD (ObjList, Operation, doc=None)
 
def process2D_ObjectsViaOpenSCADShape (ObjList, Operation, doc)
 
def process3D_ObjectsViaOpenSCAD (doc, ObjList, Operation)
 
def process3D_ObjectsViaOpenSCADShape (ObjList, Operation, maxmeshpoints=None)
 
def process_ObjectsViaOpenSCAD (doc, children, name)
 
def process_ObjectsViaOpenSCADShape (doc, children, name, maxmeshpoints=None)
 
def removesubtree (objs)
 
def resizemesh (msh, vec)
 
def reverseimporttypes ()
 
def roundrotation (rot, maxangulardistance=1e-5)
 
def scalemesh (msh, vec)
 
def searchforopenscadexe ()
 
def shorthexfloat (f)
 
def translate (context, text)
 
def vec2householder (nv)
 
def workaroundforissue128needed ()
 

Variables

 BaseError = FreeCAD.Base.FreeCADError
 
def tempfilenamegen = newtempfilename()
 

Function Documentation

◆ angneg()

def OpenSCADUtils.angneg (   d)

◆ applyPlacement()

def OpenSCADUtils.applyPlacement (   shape)

◆ call_openscad_with_pipes()

def OpenSCADUtils.call_openscad_with_pipes (   input_filename,
  output_filename,
  output_extension,
  keep_name 
)
 Call OpenSCAD by sending input data to stdin, and read the output from stdout.
    Returns the tempfile the output is stored in on success, or None on failure.
    NOTE: This feature was added to OpenSCAD in 2021.01

Referenced by callopenscad().

◆ callopenscad()

def OpenSCADUtils.callopenscad (   inputfilename,
  outputfilename = None,
  outputext = 'csg',
  keepname = False 
)
call the open scad binary
returns the filename of the result (or None),
please delete the file afterwards

References call_openscad_with_pipes().

Referenced by callopenscadstring().

◆ callopenscadmeshstring()

def OpenSCADUtils.callopenscadmeshstring (   scadstr)
Call OpenSCAD and return the result as a Mesh

References callopenscadstring().

Referenced by meshopinline(), meshoptempfile(), mirrormesh(), resizemesh(), and scalemesh().

◆ callopenscadstring()

def OpenSCADUtils.callopenscadstring (   scadstr,
  outputext = 'csg' 
)
create a tempfile and call the open scad binary
returns the filename of the result (or None),
please delete the file afterwards

References callopenscad().

Referenced by OpenSCADCommands.AddSCADTask.addelement(), callopenscadmeshstring(), prototype.openscadmesh(), and process2D_ObjectsViaOpenSCADShape().

◆ comparerotations()

def OpenSCADUtils.comparerotations (   r1,
  r2 
)

◆ decomposerotoinversion()

def OpenSCADUtils.decomposerotoinversion (   m,
  precision = 4 
)

References fcsubmatrix().

◆ detsubmatrix()

def OpenSCADUtils.detsubmatrix (   s)
get the determinant of a 3x3 Matrix given as list of row vectors

Referenced by isrotoinversionpython(), and isspecialorthogonalpython().

◆ fcsubmatrix()

def OpenSCADUtils.fcsubmatrix (   m)
Extracts the 3x3 Submatrix from a freecad Matrix Object
as a list of row vectors

Referenced by decomposerotoinversion().

◆ findbestmatchingrotation()

def OpenSCADUtils.findbestmatchingrotation (   r1)

References comparerotations().

Referenced by roundrotation().

◆ getopenscadexe()

def OpenSCADUtils.getopenscadexe (   osfilename = None)

◆ getopenscadversion()

def OpenSCADUtils.getopenscadversion (   osfilename = None)

◆ isorthogonal()

def OpenSCADUtils.isorthogonal (   submatrix,
  precision = 4 
)
checking if 3x3 Matrix is orthogonal (M*Transp(M)==I)

References multiplymat().

Referenced by isrotoinversionpython(), and isspecialorthogonalpython().

◆ isrotoinversionpython()

def OpenSCADUtils.isrotoinversionpython (   submat,
  precision = 4 
)

References detsubmatrix(), and isorthogonal().

◆ isspecialorthogonal()

def OpenSCADUtils.isspecialorthogonal (   mat,
  precision = 4 
)

◆ isspecialorthogonalpython()

def OpenSCADUtils.isspecialorthogonalpython (   submat,
  precision = 4 
)

References detsubmatrix(), and isorthogonal().

◆ meshopinline()

def OpenSCADUtils.meshopinline (   opname,
  iterable1 
)
uses OpenSCAD to combine meshes
takes the name of the CGAL operation and an iterable (tuple,list) of
FreeCAD Mesh objects
includes all the mesh data in the SCAD file

References callopenscadmeshstring().

◆ meshoponobjs()

def OpenSCADUtils.meshoponobjs (   opname,
  inobjs 
)
takes a string (operation name) and a list of Feature Objects
returns a mesh and a list of objects that were used
Part Objects will be meshed

References meshoptempfile().

◆ meshoptempfile()

def OpenSCADUtils.meshoptempfile (   opname,
  iterable1 
)
uses OpenSCAD to combine meshes
takes the name of the CGAL operation and an iterable (tuple,list) of
FreeCAD Mesh objects
uses stl files to supply the mesh data

References callopenscadmeshstring().

Referenced by meshoponobjs(), and process3D_ObjectsViaOpenSCADShape().

◆ mirror2mat()

def OpenSCADUtils.mirror2mat (   nv,
  bv 
)

◆ mirrormesh()

def OpenSCADUtils.mirrormesh (   msh,
  vec 
)
mirrormesh(mesh,vector) where mesh is a mesh object and vector is a Base.Vector

References callopenscadmeshstring().

Referenced by OpenSCADCommands.MirrorMeshFeature.Activated().

◆ multiplymat()

def OpenSCADUtils.multiplymat (   l,
  r 
)
multiply matrices given as lists of row vectors

Referenced by isorthogonal().

◆ newtempfilename()

def OpenSCADUtils.newtempfilename ( )

◆ process2D_ObjectsViaOpenSCAD()

def OpenSCADUtils.process2D_ObjectsViaOpenSCAD (   ObjList,
  Operation,
  doc = None 
)

◆ process2D_ObjectsViaOpenSCADShape()

def OpenSCADUtils.process2D_ObjectsViaOpenSCADShape (   ObjList,
  Operation,
  doc 
)

◆ process3D_ObjectsViaOpenSCAD()

def OpenSCADUtils.process3D_ObjectsViaOpenSCAD (   doc,
  ObjList,
  Operation 
)

◆ process3D_ObjectsViaOpenSCADShape()

def OpenSCADUtils.process3D_ObjectsViaOpenSCADShape (   ObjList,
  Operation,
  maxmeshpoints = None 
)

◆ process_ObjectsViaOpenSCAD()

def OpenSCADUtils.process_ObjectsViaOpenSCAD (   doc,
  children,
  name 
)

◆ process_ObjectsViaOpenSCADShape()

def OpenSCADUtils.process_ObjectsViaOpenSCADShape (   doc,
  children,
  name,
  maxmeshpoints = None 
)

◆ removesubtree()

def OpenSCADUtils.removesubtree (   objs)

◆ resizemesh()

def OpenSCADUtils.resizemesh (   msh,
  vec 
)
resizemesh(mesh,vector) where mesh is a mesh object and vector is a Base.Vector

References callopenscadmeshstring().

Referenced by OpenSCADCommands.ResizeMeshFeature.Activated().

◆ reverseimporttypes()

def OpenSCADUtils.reverseimporttypes ( )
allows to search for supported filetypes by module

◆ roundrotation()

def OpenSCADUtils.roundrotation (   rot,
  maxangulardistance = 1e-5 
)
guess the rotation axis and angle for a rotation
recreated from rounded floating point values
(from a quaterion or transformation matrix)

References comparerotations(), and findbestmatchingrotation().

◆ scalemesh()

def OpenSCADUtils.scalemesh (   msh,
  vec 
)
scalemesh(mesh,vector) where mesh is a mesh object and vector is a Base.Vector

References callopenscadmeshstring().

Referenced by OpenSCADCommands.ScaleMeshFeature.Activated().

◆ searchforopenscadexe()

def OpenSCADUtils.searchforopenscadexe ( )

◆ shorthexfloat()

def OpenSCADUtils.shorthexfloat (   f)

◆ translate()

def OpenSCADUtils.translate (   context,
  text 
)

◆ vec2householder()

def OpenSCADUtils.vec2householder (   nv)
calculated the householder matrix for a given normal vector

Referenced by mirror2mat().

◆ workaroundforissue128needed()

def OpenSCADUtils.workaroundforissue128needed ( )
sets the import path depending on the OpenSCAD Version
for versions <= 2012.06.23 to the current working dir
for versions above to the inputfile dir
see https://github.com/openscad/openscad/issues/128

References getopenscadversion().

Referenced by prototype.readfile().

Variable Documentation

◆ BaseError

OpenSCADUtils.BaseError = FreeCAD.Base.FreeCADError

◆ tempfilenamegen

def OpenSCADUtils.tempfilenamegen = newtempfilename()