Arch/Draft: Make sure an active doc exists before creating objects
This commit is contained in:
@@ -52,6 +52,9 @@ __url__ = "http://www.freecadweb.org"
|
||||
def makeAxis(num=5,size=1000,name="Axes"):
|
||||
'''makeAxis(num,size): makes an Axis set
|
||||
based on the given number of axes and interval distances'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Axis(obj)
|
||||
|
||||
@@ -193,6 +193,9 @@ BuildingTypes = ['Undefined',
|
||||
def makeBuilding(objectslist=None,baseobj=None,name="Building"):
|
||||
'''makeBuilding(objectslist): creates a building including the
|
||||
objects from the given list.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_Building(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
|
||||
@@ -198,6 +198,9 @@ def removeComponents(objectsList,host=None):
|
||||
def makeComponent(baseobj=None,name="Component",delete=False):
|
||||
'''makeComponent([baseobj]): creates an undefined, non-parametric Arch
|
||||
component from the given base object'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
ArchComponent.Component(obj)
|
||||
|
||||
@@ -57,6 +57,9 @@ Roles = ["Undefined","Furniture", "Hydro Equipment", "Electric Equipment"]
|
||||
|
||||
def makeEquipment(baseobj=None,placement=None,name="Equipment"):
|
||||
"makeEquipment([baseobj,placement,name]): creates an equipment object from the given base object."
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Equipment(obj)
|
||||
if baseobj:
|
||||
|
||||
@@ -52,6 +52,9 @@ __url__ = "http://www.freecadweb.org"
|
||||
def makeFloor(objectslist=None,baseobj=None,name="Floor"):
|
||||
'''makeFloor(objectslist): creates a floor including the
|
||||
objects from the given list.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Floor(obj)
|
||||
|
||||
@@ -54,6 +54,9 @@ Roles = ['Undefined','Covering','Member','Railing','Shading Device','Tendon']
|
||||
def makeFrame(baseobj,profile,name=translate("Arch","Frame")):
|
||||
"""makeFrame(baseobj,profile,[name]): creates a frame object from a base sketch (or any other object
|
||||
containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)"""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Frame(obj)
|
||||
|
||||
@@ -47,6 +47,9 @@ __url__ = "http://www.freecadweb.org"
|
||||
|
||||
def makeMaterial(name="Material"):
|
||||
'''makeMaterial(name): makes an Material object'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::MaterialObjectPython",name)
|
||||
obj.Label = name
|
||||
_ArchMaterial(obj)
|
||||
|
||||
@@ -66,6 +66,9 @@ def makePanel(baseobj=None,length=0,width=0,thickness=0,placement=None,name="Pan
|
||||
panel element based on the given profile object and the given
|
||||
extrusion thickness. If no base object is given, you can also specify
|
||||
length and width for a simple cubic object.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Panel(obj)
|
||||
|
||||
@@ -52,6 +52,9 @@ def makePipe(baseobj=None,diameter=0,length=0,placement=None,name="Pipe"):
|
||||
|
||||
"makePipe([baseobj,diamerter,length,placement,name]): creates an pipe object from the given base object"
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj= FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = name
|
||||
_ArchPipe(obj)
|
||||
@@ -80,6 +83,9 @@ def makePipeConnector(pipes,radius=0,name="Connector"):
|
||||
|
||||
"makePipeConnector(pipes,[radius,name]): creates a connector between the given pipes"
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj= FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = name
|
||||
_ArchPipeConnector(obj)
|
||||
|
||||
@@ -80,6 +80,9 @@ def readPresets():
|
||||
|
||||
def makeProfile(profile=[0,'REC','REC100x100','R',100,100]):
|
||||
'''makeProfile(profile): returns a shape with the face defined by the profile data'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",profile[2])
|
||||
obj.Label = translate("Arch",profile[2])
|
||||
if profile[3]=="C":
|
||||
|
||||
@@ -53,6 +53,9 @@ __url__ = "http://www.freecadweb.org"
|
||||
def makeRebar(baseobj=None,sketch=None,diameter=None,amount=1,offset=None,name="Rebar"):
|
||||
"""makeRebar([baseobj,sketch,diameter,amount,offset,name]): adds a Reinforcement Bar object
|
||||
to the given structural object, using the given sketch as profile."""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
|
||||
@@ -55,6 +55,9 @@ def makeRoof(baseobj=None,facenr=0, angles=[45.,], run = [], idrel = [0,],thickn
|
||||
roof shape. The default for angle is 45 and the list is
|
||||
automatically complete to match with number of edges in the wire.
|
||||
If the base object is a solid the roof take the shape.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
import Part
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
|
||||
@@ -48,6 +48,9 @@ else:
|
||||
def makeSectionPlane(objectslist=None,name="Section"):
|
||||
"""makeSectionPlane([objectslist]) : Creates a Section plane objects including the
|
||||
given objects. If no object is given, the whole document will be considered."""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_SectionPlane(obj)
|
||||
|
||||
@@ -54,6 +54,9 @@ __url__ = "http://www.freecadweb.org"
|
||||
def makeSite(objectslist=None,baseobj=None,name="Site"):
|
||||
'''makeBuilding(objectslist): creates a site including the
|
||||
objects from the given list.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
import Part
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
|
||||
@@ -176,6 +176,9 @@ def makeSpace(objects=None,baseobj=None,name="Space"):
|
||||
"""makeSpace([objects]): Creates a space object from the given objects. Objects can be one
|
||||
document object, in which case it becomes the base shape of the space object, or a list of
|
||||
selection objects as got from getSelectionEx(), or a list of tuples (object, subobjectname)"""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
_Space(obj)
|
||||
|
||||
@@ -49,6 +49,9 @@ else:
|
||||
def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name="Stairs"):
|
||||
"""makeStairs([baseobj,length,width,height,steps]): creates a Stairs
|
||||
objects with given attributes."""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
|
||||
@@ -69,6 +69,9 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structur
|
||||
structure element based on the given profile object and the given
|
||||
extrusion height. If no base object is given, you can also specify
|
||||
length and width for a cubic object.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
@@ -101,6 +104,9 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structur
|
||||
def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"):
|
||||
'''makeStructuralSystem(objects,axes): makes a structural system
|
||||
based on the given objects and axes'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
result = []
|
||||
if not axes:
|
||||
print("At least one axis must be given")
|
||||
|
||||
@@ -57,6 +57,9 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
|
||||
given object, which can be a sketch, a draft object, a face or a solid, or no object at
|
||||
all, then you must provide length, width and height. Align can be "Center","Left" or "Right",
|
||||
face can be an index number of a face in the base object to base the wall on.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
obj.Label = translate("Arch",name)
|
||||
|
||||
@@ -63,6 +63,9 @@ def makeWindow(baseobj=None,width=None,height=None,parts=None,name="Window"):
|
||||
'''makeWindow(baseobj,[width,height,parts,name]): creates a window based on the
|
||||
given base 2D object (sketch or draft).'''
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if baseobj:
|
||||
if Draft.getType(baseobj) == "Window":
|
||||
obj = Draft.clone(baseobj)
|
||||
@@ -112,6 +115,10 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None
|
||||
window object based on the given data. windowtype must be one of the names
|
||||
defined in Arch.WindowPresets"""
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
|
||||
def makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2):
|
||||
|
||||
import Part,Sketcher
|
||||
|
||||
@@ -666,6 +666,9 @@ def makeCircle(radius, placement=None, face=None, startangle=None, endangle=None
|
||||
wireframe, otherwise as a face. If startangle AND endangle are given
|
||||
(in degrees), they are used and the object appears as an arc. If an edge
|
||||
is passed, its Curve must be a Part.Circle'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
import Part, DraftGeomUtils
|
||||
if placement: typecheck([(placement,FreeCAD.Placement)], "makeCircle")
|
||||
if startangle != endangle:
|
||||
@@ -711,6 +714,9 @@ def makeRectangle(length, height, placement=None, face=None, support=None):
|
||||
object with length in X direction and height in Y direction.
|
||||
If a placement is given, it is used. If face is False, the
|
||||
rectangle is shown as a wireframe, otherwise as a face.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if placement: typecheck([(placement,FreeCAD.Placement)], "makeRectangle")
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Rectangle")
|
||||
_Rectangle(obj)
|
||||
@@ -741,6 +747,9 @@ def makeDimension(p1,p2,p3=None,p4=None):
|
||||
to the given object, i1 is the index of the (curved) edge to measure,
|
||||
and mode is either "radius" or "diameter".
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","Dimension")
|
||||
_Dimension(obj)
|
||||
if gui:
|
||||
@@ -802,6 +811,9 @@ def makeAngularDimension(center,angles,p3,normal=None):
|
||||
'''makeAngularDimension(center,angle1,angle2,p3,[normal]): creates an angular Dimension
|
||||
from the given center, with the given list of angles, passing through p3.
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","Dimension")
|
||||
_AngularDimension(obj)
|
||||
obj.Center = center
|
||||
@@ -835,6 +847,9 @@ def makeWire(pointslist,closed=False,placement=None,face=None,support=None):
|
||||
and last points are identical, the wire is closed. If face is
|
||||
true (and wire is closed), the wire will appear filled. Instead of
|
||||
a pointslist, you can also pass a Part Wire.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
import DraftGeomUtils, Part
|
||||
if not isinstance(pointslist,list):
|
||||
e = pointslist.Wires[0].Edges
|
||||
@@ -874,6 +889,9 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=None,support=
|
||||
with the given radius, otherwise it is inscribed. If face is True,
|
||||
the resulting shape is displayed as a face, otherwise as a wireframe.
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if nfaces < 3: return None
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Polygon")
|
||||
_Polygon(obj)
|
||||
@@ -905,6 +923,9 @@ def makeBSpline(pointslist,closed=False,placement=None,face=None,support=None):
|
||||
and last points are identical, the wire is closed. If face is
|
||||
true (and wire is closed), the wire will appear filled. Instead of
|
||||
a pointslist, you can also pass a Part Wire.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
from DraftTools import msg
|
||||
if not isinstance(pointslist,list):
|
||||
nlist = []
|
||||
@@ -944,6 +965,9 @@ def makeBSpline(pointslist,closed=False,placement=None,face=None,support=None):
|
||||
def makeBezCurve(pointslist,closed=False,placement=None,face=None,support=None,Degree=None):
|
||||
'''makeBezCurve(pointslist,[closed],[placement]): Creates a Bezier Curve object
|
||||
from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if not isinstance(pointslist,list):
|
||||
nlist = []
|
||||
for v in pointslist.Vertexes:
|
||||
@@ -982,6 +1006,9 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False):
|
||||
can also be one single string). The current color and text height and font
|
||||
specified in preferences are used.
|
||||
If screen is True, the text always faces the view direction.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
typecheck([(point,Vector)], "makeText")
|
||||
if not isinstance(stringslist,list): stringslist = [stringslist]
|
||||
obj=FreeCAD.ActiveDocument.addObject("App::Annotation","Text")
|
||||
@@ -1002,6 +1029,9 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False):
|
||||
|
||||
def makeCopy(obj,force=None,reparent=False):
|
||||
'''makeCopy(object): returns an exact copy of an object'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if (getType(obj) == "Rectangle") or (force == "Rectangle"):
|
||||
newobj = FreeCAD.ActiveDocument.addObject(obj.TypeId,getRealName(obj.Name))
|
||||
_Rectangle(newobj)
|
||||
@@ -1108,6 +1138,9 @@ def makeCopy(obj,force=None,reparent=False):
|
||||
|
||||
def makeBlock(objectslist):
|
||||
'''makeBlock(objectslist): Creates a Draft Block from the given objects'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Block")
|
||||
_Block(obj)
|
||||
obj.Components = objectslist
|
||||
@@ -1127,6 +1160,9 @@ def makeArray(baseobject,arg1,arg2,arg3,arg4=None,name="Array"):
|
||||
and ynum. In case of polar array, center is a vector, totalangle is the angle
|
||||
to cover (in degrees) and totalnum is the number of objects, including the original.
|
||||
The result is a parametric Draft Array.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
_Array(obj)
|
||||
obj.Base = baseobject
|
||||
@@ -1157,6 +1193,9 @@ def makePathArray(baseobject,pathobject,count,xlate=None,align=False,pathobjsubs
|
||||
pathobject. Optionally translates each copy by FreeCAD.Vector xlate direction
|
||||
and distance to adjust for difference in shape centre vs shape reference point.
|
||||
Optionally aligns baseobject to tangent/normal/binormal of path.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PathArray")
|
||||
_PathArray(obj)
|
||||
obj.Base = baseobject
|
||||
@@ -1185,6 +1224,9 @@ def makeEllipse(majradius,minradius,placement=None,face=True,support=None):
|
||||
'''makeEllipse(majradius,minradius,[placement],[face],[support]): makes
|
||||
an ellipse with the given major and minor radius, and optionally
|
||||
a placement.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Ellipse")
|
||||
_Ellipse(obj)
|
||||
if minradius > majradius:
|
||||
@@ -1206,6 +1248,9 @@ def makeEllipse(majradius,minradius,placement=None,face=True,support=None):
|
||||
def makeVisGroup(group=None,name="VisGroup"):
|
||||
'''makeVisGroup([group]): creates a VisGroup object in the given group, or in the
|
||||
active document if no group is given'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
|
||||
_VisGroup(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -1219,6 +1264,9 @@ def extrude(obj,vector,solid=False):
|
||||
'''makeExtrusion(object,vector): extrudes the given object
|
||||
in the direction given by the vector. The original object
|
||||
gets hidden.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
newobj = FreeCAD.ActiveDocument.addObject("Part::Extrusion","Extrusion")
|
||||
newobj.Base = obj
|
||||
newobj.Dir = vector
|
||||
@@ -1235,6 +1283,9 @@ def fuse(object1,object2):
|
||||
the union of the 2 given objects. If the objects are
|
||||
coplanar, a special Draft Wire is used, otherwise we use
|
||||
a standard Part fuse.'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
import DraftGeomUtils, Part
|
||||
# testing if we have holes:
|
||||
holes = False
|
||||
@@ -1267,6 +1318,9 @@ def fuse(object1,object2):
|
||||
return obj
|
||||
|
||||
def cut(object1,object2):
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
'''cut(oject1,object2): returns a cut object made from
|
||||
the difference of the 2 given objects.'''
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Cut","Cut")
|
||||
@@ -2587,6 +2641,9 @@ def makeDrawingView(obj,page,lwmod=None,tmod=None,otherProjection=None):
|
||||
given page. lwmod modifies lineweights (in percent), tmod modifies text heights
|
||||
(in percent). The Hint scale, X and Y of the page are used.
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if getType(obj) == "SectionPlane":
|
||||
import ArchSectionPlane
|
||||
viewobj = FreeCAD.ActiveDocument.addObject("Drawing::FeatureViewPython","View")
|
||||
@@ -2639,6 +2696,9 @@ def makeShape2DView(baseobj,projectionVector=None,facenumbers=[]):
|
||||
2D projection of the given object. A specific projection vector can also be given. You can also
|
||||
specify a list of face numbers to be considered in individual faces mode.
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Shape2DView")
|
||||
_Shape2DView(obj)
|
||||
if gui:
|
||||
@@ -2678,6 +2738,10 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,
|
||||
precision, and 'Equal' constraint will be added to curve with equal
|
||||
radius within precision.'''
|
||||
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
|
||||
import Part, DraftGeomUtils
|
||||
from Sketcher import Constraint
|
||||
import Sketcher
|
||||
@@ -2942,6 +3006,9 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5):
|
||||
p1.X = 1 #move it in x
|
||||
p1.ViewObject.PointColor =(0.0,0.0,1.0) #change the color-make sure values are floats
|
||||
'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
if isinstance(X,FreeCAD.Vector):
|
||||
Z = X.z
|
||||
@@ -2965,6 +3032,9 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5):
|
||||
def makeShapeString(String,FontFile,Size = 100,Tracking = 0):
|
||||
'''ShapeString(Text,FontFile,Height,Track): Turns a text string
|
||||
into a Compound Shape'''
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","ShapeString")
|
||||
_ShapeString(obj)
|
||||
obj.String = String
|
||||
@@ -3154,6 +3224,9 @@ def heal(objlist=None,delete=True,reparent=True):
|
||||
def makeFacebinder(selectionset,name="Facebinder"):
|
||||
"""makeFacebinder(selectionset,[name]): creates a Facebinder object from a selection set.
|
||||
Only faces will be added."""
|
||||
if not FreeCAD.ActiveDocument:
|
||||
FreeCAD.Console.PrintError("No active document. Aborting\n")
|
||||
return
|
||||
if not isinstance(selectionset,list):
|
||||
selectionset = [selectionset]
|
||||
fb = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||
|
||||
Reference in New Issue
Block a user