-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFoamCut_WorkingPlane.py
70 lines (54 loc) · 2.35 KB
/
FoamCut_WorkingPlane.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
__title__ = "Create Rotation"
__author__ = "Andrew Shkolik"
__license__ = "LGPL 2.1"
__doc__ = "Working plane."
import FreeCAD
App=FreeCAD
import FreeCADGui
Gui=FreeCADGui
import FoamCutBase
import FoamCutViewProviders
import utilities
import Part
class FoamCutWorkingPlane(FoamCutBase.FoamCutBaseObject):
def __init__(self, obj, jobName, side):
super().__init__(obj, jobName)
obj.Type = "Helper"
obj.addProperty("App::PropertyLength", "Length", "", "", 5).Length = 100 # Machine X axis
obj.addProperty("App::PropertyLength", "Width", "", "", 5).Width = 100 # Machine Y axis
obj.addProperty("App::PropertyPosition", "Position", "", "", 5).Position = App.Vector(0.0, 0.0, 0.0) # Machine base X axis
config = self.getConfigName(obj)
obj.setExpression(".Width", u"<<{}>>.VerticalTravel".format(config))
obj.setExpression(".Length", u"<<{}>>.HorizontalTravel".format(config))
obj.setExpression(".Position.y", u"-<<{}>>.OriginX".format(config))
if side == utilities.LEFT:
obj.setExpression(".Position.x", u"-<<{}>>.FieldWidth / 2".format(config))
else:
obj.setExpression(".Position.x", u"<<{}>>.FieldWidth / 2".format(config))
obj.Proxy = self
self.execute(obj)
# Gui.Selection.clearSelection()
def execute(self, obj):
norm = App.Vector(1.0, 0.0, 0.0)
xdir = App.Vector(0.0, 1.0, 0.0)
plane = Part.makePlane(obj.Length, obj.Width, obj.Position, norm, xdir)
obj.Shape = plane
obj.Placement = plane.Placement
class FoamCutWorkingPlaneVP(FoamCutViewProviders.FoamCutBaseViewProvider):
def __init__(self, obj):
obj.LineColor = (255, 225, 5)
obj.ShapeColor = (255, 225, 5)
obj.PointColor = (255, 225, 5)
obj.LineWidth = 1
obj.PointSize = 1
obj.Proxy = self
obj.Transparency = 80
def attach(self, obj):
self.ViewObject = obj
self.Object = obj.Object
def getIcon(self):
return utilities.getIconPath("plane.svg")
def CreateWorkingPlane(obj, jobName, side):
FoamCutWorkingPlane(obj, jobName, side)
FoamCutWorkingPlaneVP(obj.ViewObject)