def Activated(self): sel = Gui.Selection.getSelection() if len(sel) == 4: mode = '4sided' elif len(sel) == 3: mode = '3sided' if mode == '4sided': poly0 = Gui.Selection.getSelection()[0] poly1 = Gui.Selection.getSelection()[1] poly2 = Gui.Selection.getSelection()[2] poly3 = Gui.Selection.getSelection()[3] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGrid44_4") AN.ControlGrid44_4(a, poly0, poly1, poly2, poly3) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.67, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.33, 1.00) FreeCAD.ActiveDocument.recompute() if mode == '3sided': poly0 = Gui.Selection.getSelection()[0] poly1 = Gui.Selection.getSelection()[1] poly2 = Gui.Selection.getSelection()[2] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGrid44_3") a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) AN.ControlGrid44_3(a, poly0, poly1, poly2) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.67, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.33, 1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): sel = Gui.Selection.getSelection() N = len(sel) if N == 1: a = FreeCAD.ActiveDocument.addObject( "Part::FeaturePython", "ControlGridNStar66_StarTrim") AN.ControlGridNStar66_StarTrim(a, sel[0]) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (1.00, 0.67, 0.00) a.ViewObject.PointSize = 2.00 a.ViewObject.PointColor = (1.00, 1.00, 0.00) elif N > 1: SubList = [0] * N for i in range(N): SubList[i] = Gui.Selection.getSelection()[i] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGridNStar66_NSub") AN.ControlGridNStar66_NSub(a, SubList) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (1.00, 0.67, 0.00) a.ViewObject.PointSize = 2.00 a.ViewObject.PointColor = (1.00, 1.00, 0.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): sel = Gui.Selection.getSelection() selx = Gui.Selection.getSelectionEx()[0] NL_Grid = selx.Object # this is a resilient link to the underlying object Pick = selx.PickedPoints[ 0] # this is the point where the grid was picked. this corner will be rounded #3D view pick is not in tolerance for == check to grid points test_scale = (NL_Grid.Poles[15] - NL_Grid.Poles[0]).Length if ((NL_Grid.Poles[0] - Pick).Length / test_scale) < 0.0001: Corner = 0 print 'corner 0 at Grid index 0' elif ((NL_Grid.Poles[3] - Pick).Length / test_scale) < 0.0001: Corner = 1 print 'corner 1 at Grid index 3' elif ((NL_Grid.Poles[15] - Pick).Length / test_scale) < 0.0001: Corner = 2 print 'corner 2 at Grid index 15' elif ((NL_Grid.Poles[12] - Pick).Length / test_scale) < 0.0001: Corner = 3 print 'corner 3 at Grid index 12' else: print 'unable to identify which corner the grid was pick on. please select the grid by one of its corners in the 3D view' a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGrid64_3_Grid44") AN.ControlGrid64_3_1Grid44(a, NL_Grid, Corner) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.67, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.33, 1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): sel = Gui.Selection.getSelection() if len(sel) == 4: mode = '4sided' elif len(sel) != 4: mode = 'undefined' if mode == '4sided': poly0 = Gui.Selection.getSelection()[0] poly1 = Gui.Selection.getSelection()[1] poly2 = Gui.Selection.getSelection()[2] poly3 = Gui.Selection.getSelection()[3] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGrid64_4") AN.ControlGrid64_4(a, poly0, poly1, poly2, poly3) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.67, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.33, 1.00) FreeCAD.ActiveDocument.recompute() if mode == 'undefined': print( 'please select 4 control polygons forming a loop in the following order: 6P, 4P, 6P, 4P' )
def Activated(self): sel = Gui.Selection.getSelection() if len(sel) == 1: if sel[0].GeometryCount == 3: mode = '3L' else: #if sel[0].GeometryCount==1 or sel[0].GeometryCount==8: mode = 'FirstElement' elif len(sel) == 2: mode = '2N' print mode if mode == '3L': sketch = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly4_3L") AN.ControlPoly4_3L(a, sketch) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == 'FirstElement': sketch = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly4_FirstElement") AN.ControlPoly4_FirstElement(a, sketch) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == '2N': sketch0 = Gui.Selection.getSelection()[0] sketch1 = Gui.Selection.getSelection()[1] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly4_2N") AN.ControlPoly4_2N(a, sketch0, sketch1) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): poly=Gui.Selection.getSelection()[0] a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","CubicSurface_66") AN.CubicSurface_66(a,poly) a.ViewObject.Proxy=0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.DisplayMode = u"Shaded" a.ViewObject.ShapeColor = (0.33,0.67,1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): poly = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "CubicCurve_4") AN.CubicCurve_4(a, poly) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (1.00, 0.67, 0.00) a.ViewObject.PointSize = 2.00 a.ViewObject.PointColor = (1.00, 1.00, 0.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): surface = Gui.Selection.getSelection()[0] curve = Gui.Selection.getSelection()[1] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlGrid44_EdgeSegment") AN.ControlGrid44_EdgeSegment(a, surface, curve) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.67, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.33, 1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): sel = Gui.Selection.getSelection() Surf_0 = Gui.Selection.getSelection()[0] Surf_1 = Gui.Selection.getSelection()[1] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "SubGrid63_2Surf64") AN.SubGrid63_2Surf64(a, Surf_0, Surf_1) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (1.00, 0.67, 0.00) a.ViewObject.PointSize = 2.00 a.ViewObject.PointColor = (1.00, 1.00, 0.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): selx=Gui.Selection.getSelectionEx() NL_Curve=selx[0].Object # this is a resilient link to the underlying object Point_onCurve_0=selx[1].Object # this is a resilient link to the underlying object Point_onCurve_1=selx[2].Object # this is a resilient link to the underlying object a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ControlPoly4_segment") AN.ControlPoly4_segment(a,NL_Curve, Point_onCurve_0, Point_onCurve_1) a.ViewObject.Proxy=0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00,1.00,1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00,0.00,1.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): sel=Gui.Selection.getSelection() Sub_0=Gui.Selection.getSelection()[0] Sub_1=Gui.Selection.getSelection()[1] Sub_2=Gui.Selection.getSelection()[2] SubList = [Sub_0, Sub_1, Sub_2] a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ControlGrid3Star66_3Sub") AN.ControlGrid3Star66_3Sub(a,SubList) a.ViewObject.Proxy=0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (1.00,0.67,0.00) a.ViewObject.PointSize = 2.00 a.ViewObject.PointColor = (1.00,1.00,0.00) FreeCAD.ActiveDocument.recompute()
def Activated(self): selx = Gui.Selection.getSelectionEx()[0] NL_Curve = selx.Object # this is a resilient link to the underlying object Pick = selx.PickedPoints[ 0] # this is the point where the curve was picked u = NL_Curve.Shape.Curve.parameter( Pick) # picked point is used for an initial value a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Point_onCurve") AN.Point_onCurve(a, NL_Curve, u) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.PointSize = 5.00 a.ViewObject.PointColor = (1.00, 0.00, 0.00) FreeCAD.ActiveDocument.recompute()
def makeNSurf(self, fp, HomogeneousGrids, N): NSurf = [0] * N for i in range(N): NSurf[i] = AN.NURBS_Cubic_66_surf(HomogeneousGrids[i]) return NSurf
def Activated(self): sel = Gui.Selection.getSelection() if len(sel) == 1: try: if sel[0].Shape.Curve.NbPoles == 4: mode = 'Bezier' except Exception: pass try: if sel[0].GeometryCount == 5: mode = '5L' except Exception: pass try: if sel[0].Shape.Curve.NbPoles != 4 or sel[0].GeometryCount != 5: #if isinstance(sel[0].Geometry[0], Part.ArcOfCircle): mode = 'FirstElement' except Exception: pass if len(sel) == 2: if sel[0].TypeId == 'Sketcher::SketchObject' and sel[ 1].TypeId == 'Sketcher::SketchObject': mode = '2N' try: if sel[0].Shape.Curve.NbPoles == 4 and sel[ 1].Shape.Curve.NbPoles == 4: mode = 'FilletBezier' except Exception: pass print('selection processed as ', mode, ' operation') if mode == '5L': sketch = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly6_5L") AN.ControlPoly6_5L(a, sketch) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == 'FirstElement': sketch = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly6_FirstElement") AN.ControlPoly6_FirstElement(a, sketch) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == 'Bezier': bezier = Gui.Selection.getSelection()[0] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly6_Bezier") AN.ControlPoly6_FirstElement(a, bezier) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == '2N': sketch0 = Gui.Selection.getSelection()[0] sketch1 = Gui.Selection.getSelection()[1] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly6_2N") AN.ControlPoly6_2N(a, sketch0, sketch1) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute() if mode == 'FilletBezier': CubicCurve4_0 = Gui.Selection.getSelection()[0] CubicCurve4_1 = Gui.Selection.getSelection()[1] a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ControlPoly6_FilletBezier") AN.ControlPoly6_FilletBezier(a, CubicCurve4_0, CubicCurve4_1) a.ViewObject.Proxy = 0 # just set it to something different from None (this assignment is needed to run an internal notification) a.ViewObject.LineWidth = 1.00 a.ViewObject.LineColor = (0.00, 1.00, 1.00) a.ViewObject.PointSize = 4.00 a.ViewObject.PointColor = (0.00, 0.00, 1.00) FreeCAD.ActiveDocument.recompute()