Merge pull request #3 from mahaarbo/freecad0.17

Support for FreeCAD >0.16
This commit is contained in:
mahaarbo 2019-02-12 11:16:17 +01:00 committed by GitHub
commit bb0b9217dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 20 deletions

View file

@ -161,7 +161,7 @@ class ViewProviderFrame(object):
pl = fp.getPropertyByName("Placement")
self.transform.translation = (pl.Base.x,
pl.Base.y,
pl.Base.Z)
pl.Base.z)
self.transform.rotation = pl.Rotation.Q
def getDisplayModes(self, vobj):
@ -309,7 +309,7 @@ class FeatureFramePanel:
else:
FreeCAD.Console.PrintError("Multipart selection not available.")
self.reject()
if not selected.HasSubObjects:
FreeCAD.Console.PrintError("Part selected not feature.")
self.reject()
@ -356,7 +356,6 @@ class FeatureFramePanel:
QtCore.QObject.connect(self.form.ChoicesBox,
QtCore.SIGNAL("currentIndexChanged(QString)"),
self.choiceChanged)
# Setting up relevant illustrations
self.scenes = {}
for choice in self.choices:
sc = QtGui.QGraphicsScene()
@ -376,9 +375,12 @@ class FeatureFramePanel:
"PointOnSurface": PointOnSurfacePanel,
"Center": CenterPanel,
"PointOnCenterline": PointOnCenterlinePanel}
new_panel = paneldict[sel_choice](self.selected, self.so_desc)
pan = paneldict[sel_choice](self.selected, self.so_desc)
FreeCADGui.Control.closeDialog()
FreeCADGui.Control.showDialog(new_panel)
# The dialog is actually closed after the accept function has
# completed. So we need to use a delayed task to open the new dialog:
QtCore.QTimer.singleShot(0,
lambda: FreeCADGui.Control.showDialog(pan))
def reject(self):
FreeCADGui.Control.closeDialog()

View file

@ -393,7 +393,9 @@ def exportPartInfoAndFeaturesDialogue():
appendFeatureFrames(unique_selected[0], ofile)
if len(unique_selected) > 1:
FreeCAD.Console.PrintWarning("Multi-part export not yet supported.\n")
FreeCAD.Console.PrintMessage("Feature frames of " + str(unique_selected[0].Label) + " exported to " + str(ofile) + "\n")
FreeCAD.Console.PrintMessage("Feature frames of "
+ str(unique_selected[0].Label)
+ " exported to " + str(ofile) + "\n")
###################################################################
@ -419,7 +421,7 @@ def getPrimitiveInfo(prim_type, subobj, scale=1e-3):
d["radius"] = scale*subobj.Curve.Radius
d["center"] = vector2list(subobj.Curve.Center, scale)
d["axis"] = vector2list(subobj.Curve.Axis, scale=1)
d["paramerrange"] = subobj.ParameterRange
d["parameterrange"] = subobj.ParameterRange
elif prim_type == "ArcOfEllipse":
d["center"] = vector2list(subobj.Curve.Center, scale)
d["axis"] = vector2list(subobj.Curve.Axis, scale=1)
@ -446,7 +448,7 @@ def getPrimitiveInfo(prim_type, subobj, scale=1e-3):
d["radius"] = scale*subobj.Curve.Radius
d["center"] = vector2list(subobj.Curve.Center, scale)
d["axis"] = vector2list(subobj.Curve.Axis, scale=1)
d["paramerrange"] = subobj.ParameterRange
d["parameterrange"] = subobj.ParameterRange
elif prim_type == "Ellipse":
d["center"] = vector2list(subobj.Curve.Center, scale)
d["axis"] = vector2list(subobj.Curve.Axis, scale=1)
@ -459,17 +461,28 @@ def getPrimitiveInfo(prim_type, subobj, scale=1e-3):
d["center"] = vector2list(subobj.Curve.Center, scale)
d["majorradius"] = scale*subobj.Curve.MajorRadius
d["minorradius"] = scale*subobj.Curve.MinorRadius
d["parameterrange"] = subobj.ParameterRange
d["parameterrange"] = subobj.ParameterRange
elif prim_type == "Parabola":
d["anglexu"] = subobj.Curve.AngleXU
d["axis"] = vector2list(subobj.Curve.Axis, scale=1)
d["center"] = vector2list(subobj.Curve.Center, scale)
d["focal"] = scale*subobj.Curve.Focal
elif prim_type == "Line":
if not subobj.Curve.Infinite:
d["startpoint"] = vector2list(subobj.Curve.StartPoint)
d["endpoint"] = vector2list(subobj.Curve.EndPoint)
d["infinite"] = subobj.Curve.Infinite
if int(FreeCAD.Version()[1]) > 16:
sp = subobj.valueAt(subobj.FirstParameter)
ep = subobj.valueAt(subobj.LastParameter)
d["startpoint"] = vector2list(sp)
d["endpoint"] = vector2list
else:
if not hasattr(subobj.Curve, "Infinite"):
d["startpoint"] = vector2list(subobj.Curve.StartPoint)
d["endpoint"] = vector2list(subobj.Curve.EndPoint)
if hasattr(subobj.Curve, "Infinite"):
if subobj.Curve.Infinite:
d["infinite"] = subobj.Curve.Infinite
else:
d["startpoint"] = vector2list(subobj.Curve.StartPoint)
d["endpoint"] = vector2list(subobj.Curve.EndPoint)
elif prim_type == "BSplineSurface":
FreeCAD.Console.PrintWarning("getPrimitiveInfo of BSpline incomplete.")
elif prim_type == "BezierSurface":

View file

@ -3,18 +3,17 @@
Annotation for robotics bench. A FreeCAD workbench for annotating frames of interest, exporting these w.r.t. the part frame, and exporting part information.
# Installation instructions
This workbench uses freecad 0.16 so far.
This workbench supports versions of FreeCAD>0.16.
0. If you're on ubuntu 14.04, you have to run: `sudo add-apt-reposityory ppa:freecad-maintainers/freecad-stable` then `sudo apt-get update`,
1. Install FreeCAD
`sudo apt-get install Freecad`
2. Custom workbenches are located in `.FreeCAD/Mod/` under your home directory
1. [Install FreeCAD](https://www.freecadweb.org/wiki/Installing)
2. If you're not on Ubuntu follow the [workbench installation instructions](https://www.freecadweb.org/wiki/How_to_install_additional_workbenches) or you can do the following on Ubuntu.
3. Custom workbenches are located in `.FreeCAD/Mod/` under your home directory
`cd ~/.FreeCAD/Mod/`
3. Either
- Clone the repository there
- symlink the cloned repo in there
- symlink the cloned repo in there (`ln -s ./ARBench ~/.FreeCAD/ARBench`)
4. Start the workbench by
1. Run FreeCAD
1. Running FreeCAD
2. Open a STEP file
3. Open the `ARBench` workbench