Пример #1
0
    def OnRevolve(self, event):
        if cad.GetNumSelected() == 0:
            self.PickObjects('Pick Some Sketches, Faces or Circles')

        if not self.CheckForNumberOrMore(
                1,
            [
                cad.OBJECT_TYPE_SKETCH,
                step.GetFaceType(), cad.OBJECT_TYPE_CIRCLE
            ], 'Pick one or more sketches, faces or circles, to create an extruded body from\n( hold down Ctrl key to select more than one solid )',
                'Revolve'):
            return

        config = HeeksConfig()
        angle = config.ReadFloat('RevolutionAngle', 360.0)
        extrude_makes_a_solid = config.ReadBool('ExtrudeToSolid')

        success, angle, extrude_makes_a_solid = self.InputRevolutionAngle(
            angle, extrude_makes_a_solid)

        if success:
            config.WriteFloat('RevolutionAngle', angle)
            config.WriteBool('ExtrudeToSolid', extrude_makes_a_solid)
            step.CreateExtrusion(angle, extrude_makes_a_solid, True, 0.0,
                                 cad.Color(128, 128, 150))
Пример #2
0
    def OnSweep(self, event):
        if cad.GetNumSelected() == 0:
            self.PickObjects('Pick Some Sketches, Faces or Circles')

        if not self.CheckForNumberOrMore(
                1,
            [
                cad.OBJECT_TYPE_SKETCH,
                step.GetFaceType(), cad.OBJECT_TYPE_CIRCLE
            ], 'Pick one or more sketches, faces or circles, to sweep\n( hold down Ctrl key to select more than one solid )',
                'Sweep'):
            return

        sweep_objects = cad.GetSelectedObjects()
        cad.ClearSelection(True)
        self.PickObjects('Pick a Sketch to Sweep Along')

        if not self.CheckForNumberOrMore(1, [cad.OBJECT_TYPE_SKETCH],
                                         'Pick one sketch to sweep along',
                                         'Sweep'):
            return

        sweep_profile = cad.GetSelectedObjects()[0]

        cad.StartHistory()
        step.CreateSweep(sweep_objects, sweep_profile,
                         cad.Color(128, 150, 128))
        cad.EndHistory()
Пример #3
0
    def OnExtrude(self, event):
        if cad.GetNumSelected() == 0:
            self.PickObjects('Pick Some Sketches, Faces or Circles')

        if not self.CheckForNumberOrMore(
                1,
            [
                cad.OBJECT_TYPE_SKETCH,
                step.GetFaceType(), cad.OBJECT_TYPE_CIRCLE
            ], 'Pick one or more sketches, faces or circles, to create an extruded body from\n( hold down Ctrl key to select more than one solid )',
                'Extude'):
            return

        config = HeeksConfig()
        height = config.ReadFloat('ExtrusionHeight', 10.0)
        taper_angle = config.ReadFloat('ExtrusionTaperAngle', 0.0)
        extrude_makes_a_solid = config.ReadBool('ExtrudeToSolid')

        success, height, extrude_makes_a_solid, taper_angle = self.InputExtrusionHeight(
            height, extrude_makes_a_solid, taper_angle)

        if success:
            config.WriteFloat('ExtrusionHeight', height)
            config.WriteFloat('ExtrusionTaperAngle', taper_angle)
            config.WriteBool('ExtrudeToSolid', extrude_makes_a_solid)
            step.CreateExtrusion(height, extrude_makes_a_solid, False,
                                 taper_angle, cad.Color(128, 128, 128))
Пример #4
0
 def __init__(self, mod=1.0, num_teeth=12):
     Object.__init__(self, 0)
     self.tm = geom.Matrix()
     self.numTeeth = num_teeth
     self.module = mod
     self.addendumOffset = 0.0
     self.addendumMultiplier = 1.0
     self.dedendumMultiplier = 1.0
     self.pressureAngle = 0.34906585039886  # 20 degrees
     self.tipRelief = 0.05
     self.color = cad.Color(128, 128, 128)
Пример #5
0
def XMLRead():
    new_object = Wing()
    s = cad.GetXmlValue('col')
    if s != '':
        new_object.color = cad.Color(int(s))
    for i in range(0, len(sketch_xml_names)):
        new_object.sketch_ids[i] = int(cad.GetXmlValue(sketch_xml_names[i]))
    s = cad.GetXmlValue('mirror')
    if s != '': new_object.values['mirror'] = bool(s)

    return new_object
Пример #6
0
    def OnGlCommands(self, select, marked, no_color):
        if marked and not select:
            tool = Tool.FindTool(self.tool_number)
            if tool == None:
                return
            radius = tool.CuttingRadius(True)
            global circle_sketch
            global arc1
            global arc2

            # get 3d position from the point objects, sorted by distance from camera
            forwards = wx.GetApp(
            ).frame.graphics_canvas.viewport.view_point.Forwards()
            lens_point = wx.GetApp(
            ).frame.graphics_canvas.viewport.view_point.lens_point
            posns = []
            for point in self.points:
                object = cad.GetObjectFromId(cad.OBJECT_TYPE_POINT, point)
                if object == None:
                    continue
                pos = object.GetStartPoint()
                dotp = (lens_point - pos) * forwards
                posns.append(DotpAndPos(dotp, pos))

            posns = sorted(posns)

            for dotp_and_pos in posns:
                pos = dotp_and_pos.pos
                p0 = pos + geom.Point3D(-radius, 0, 0)
                p1 = pos + geom.Point3D(radius, 0, 0)

                if circle_sketch == None:
                    circle_sketch = cad.NewSketch()
                    arc1 = cad.NewArc(p0, p1, geom.Point3D(0, 0, 1), pos)
                    arc2 = cad.NewArc(p1, p0, geom.Point3D(0, 0, 1), pos)
                    circle_sketch.Add(arc1)
                    circle_sketch.Add(arc2)
                else:
                    arc1.SetStartPoint(p0)
                    arc1.SetEndPoint(p1)
                    arc1.SetCentrePoint(pos)
                    arc2.SetStartPoint(p1)
                    arc2.SetEndPoint(p0)
                    arc2.SetCentrePoint(pos)

                cad.Material(cad.Color(255, 255, 0)).glMaterial(1.0)
                cad.DrawEnableLighting()
                cad.DrawDisableDepthTesting()
                cad.DrawEnableCullFace()
                cad.Sketch.RenderAsExtrusion(circle_sketch, self.start_depth,
                                             self.final_depth)
                cad.DrawDisableCullFace()
                cad.DrawEnableDepthTesting()
                cad.DrawDisableLighting()
Пример #7
0
 def OnGlCommands(self, select, marked, no_color):
     if marked and not select:
         object = cad.GetObjectFromId(cad.OBJECT_TYPE_SKETCH, self.sketch)
         if object != None:
             cad.Material(cad.Color(255, 255, 0)).glMaterial(1.0)
             cad.DrawEnableLighting()
             #cad.DrawDisableDepthTesting()
             cad.DrawEnableCullFace()
             cad.Sketch.RenderAsExtrusion(object, self.start_depth, self.final_depth)
             cad.DrawDisableCullFace()
             #cad.DrawEnableDepthTesting()
             cad.DrawDisableLighting()
Пример #8
0
    def __init__(self):
        Object.__init__(self)
        self.SetUsesGLList(True)

        # properties
        self.sketch_ids = [0, 0, 0, 0, 0]
        self.values = {
            'mirror': False,
            'centre_straight': True,
        }
        self.color = cad.Color(128, 128, 128)

        self.box = None  # if box is None, then the curves need reloading
        self.ResetCurves()
Пример #9
0
    def ReadXml(self):
        self.color = cad.Color(cad.GetXmlInt('col', self.color.ref()))
        for i in range(0, len(sketch_xml_names)):
            self.sketch_ids[i] = cad.GetXmlInt(sketch_xml_names[i], 0)
        self.mirror = cad.GetXmlBool('mirror')
        self.centre_straight = cad.GetXmlBool('centre_straight')
        self.render_wing = cad.GetXmlBool('render_wing', True)
        self.render_pattern = cad.GetXmlBool('render_pattern', False)
        self.pattern_border = cad.GetXmlFloat('pattern_border', 10.0)
        self.pattern_x_step = cad.GetXmlFloat('pattern_x_step', 20.0)
        self.pattern_y_step = cad.GetXmlFloat('pattern_y_step', 30.0)
        self.pattern_wall = cad.GetXmlFloat('pattern_wall', 2.0)
        self.split_into_pieces = cad.GetXmlInt('split_into_pieces', 6)
        self.split_wall_width = cad.GetXmlFloat('split_wall_width', 4.0)

        Object.ReadXml(self)
Пример #10
0
    def __init__(self):
        Object.__init__(self, 0)

        # properties
        self.sketch_ids = [0, 0, 0, 0, 0]
        self.mirror = False
        self.centre_straight = True
        self.render_wing = True
        self.render_pattern = False
        self.pattern_border = 0.0
        self.pattern_x_step = 30.0
        self.pattern_wall = 2.0
        self.split_into_pieces = 0
        self.split_wall_width = 0.0
        self.color = cad.Color(128, 128, 128)
        self.draw_list = None

        self.box = None  # if box is None, then the curves need reloading
        self.ResetCurves()
Пример #11
0
    def OnPropGridChange(self, event):
        self.in_OnPropGridChange = True
        p = event.GetProperty()
        properties = self.GetProperties(p)
        if properties == None:
            return

        cad.StartHistory()

        for property in properties:
            if property.GetType(
            ) == cad.PROPERTY_TYPE_STRING or property.GetType(
            ) == cad.PROPERTY_TYPE_LONG_STRING:
                cad.ChangePropertyString(p.GetValue(), property)
            elif property.GetType() == cad.PROPERTY_TYPE_DOUBLE:
                cad.ChangePropertyDouble(p.GetValue(), property)
            elif property.GetType() == cad.PROPERTY_TYPE_LENGTH:
                cad.ChangePropertyLength(p.GetValue() * cad.GetUnits(),
                                         property)
            elif property.GetType() == cad.PROPERTY_TYPE_INT:
                cad.ChangePropertyInt(p.GetValue(), property)
            elif property.GetType() == cad.PROPERTY_TYPE_CHOICE:
                cad.ChangePropertyChoice(p.GetValue(), property)
            elif property.GetType() == cad.PROPERTY_TYPE_COLOR:
                c = p.GetValue()
                cad.ChangePropertyColor(cad.Color(c.red, c.green, c.blue),
                                        property)
            elif property.GetType() == cad.PROPERTY_TYPE_CHECK:
                cad.ChangePropertyCheck(p.GetValue(), property)
            elif property.GetType() == cad.PROPERTY_TYPE_LIST:
                pass
            elif property.GetType() == cad.PROPERTY_TYPE_FILE:
                cad.ChangePropertyString(p.GetValue(), property)

        #for changer in changers:
        #cad.DoUndoable(changer)

        cad.EndHistory()

        self.in_OnPropGridChange = False
Пример #12
0
    def LoadConfig(self):
        config = HeeksConfig(self.settings_restored)
        self.LoadRecentFiles(config)

        # snapping
        cad.SetDigitizeEnd(config.ReadBool("Endof", True))
        cad.SetDigitizeInters(config.ReadBool("Inters", False))
        cad.SetDigitizeCentre(config.ReadBool("Centre", True))
        cad.SetDigitizeMidpoint(config.ReadBool("Midpoint", False))
        cad.SetDigitizeSnapToGrid(config.ReadBool("Grid", True))
        
        cad.SetRotateUpright(config.ReadBool("RotateUpright", False))
        self.graphics_text_mode = config.ReadInt("TextMode", GraphicsTextModeWithHelp)
        
        cad.SetBackgroundColor(0, cad.Color(config.ReadInt("BackgroundColor0", cad.Color(230, 255, 255).ref())))
        cad.SetBackgroundColor(1, cad.Color(config.ReadInt("BackgroundColor1", cad.Color(255, 255, 255).ref())))
        cad.SetCurrentColor(cad.Color(config.ReadInt("CurrentColor", cad.Color(0, 0, 0).ref())))
        cad.SetAntialiasing(config.ReadBool('Antialiasing', False))
        cad.SetShowDatum(config.ReadBool('ShowDatum', True))
Пример #13
0
def ReadNCCodeColorsFromConfig():
    config = HeeksConfig()
    cam.ClearNcCodeColors()
    cam.AddNcCodeColor('default', cad.Color(int(config.Read('ColorDefaultType', str(cad.Color(0,0,0).ref())))))
    cam.AddNcCodeColor('blocknum', cad.Color(int(config.Read('ColorBlockType', str(cad.Color(0,0,222).ref())))))
    cam.AddNcCodeColor('misc', cad.Color(int(config.Read('ColorMiscType', str(cad.Color(0,200,0).ref())))))
    cam.AddNcCodeColor('program', cad.Color(int(config.Read('ColorProgramType', str(cad.Color(255,128,0).ref())))))
    cam.AddNcCodeColor('tool', cad.Color(int(config.Read('ColorToolType', str(cad.Color(200,200,0).ref())))))
    cam.AddNcCodeColor('comment', cad.Color(int(config.Read('ColorCommentType', str(cad.Color(0,200,200).ref())))))
    cam.AddNcCodeColor('variable', cad.Color(int(config.Read('ColorVariableType', str(cad.Color(164,88,188).ref())))))
    cam.AddNcCodeColor('prep', cad.Color(int(config.Read('ColorPrepType', str(cad.Color(255,0,175).ref())))))
    cam.AddNcCodeColor('axis', cad.Color(int(config.Read('ColorAxisType', str(cad.Color(128,0,255).ref())))))
    cam.AddNcCodeColor('rapid', cad.Color(int(config.Read('ColorRapidType', str(cad.Color(222,0,0).ref())))))
    cam.AddNcCodeColor('feed', cad.Color(int(config.Read('ColorFeedType', str(cad.Color(0,179,0).ref())))))
Пример #14
0
 def wxToCadColor(self, wxcolor):
     c = cad.Color()
     c.red = wxcolor.red
     c.green = wxcolor.green
     c.blue = wxcolor.blue
     return c
Пример #15
0
 def OnGlCommands(self, select, marked, no_color):
     if not no_color: cad.DrawColor(cad.Color(0, 0, 0))
     cad.DrawSymbol(3 if marked or cad.ObjectMarked(self) else 0,
                    self.pos.x, self.pos.y, 0.0)
     if not no_color: cad.DrawColor(cad.Color(0, 255, 0))
     cad.DrawSymbol(1, self.pos.x, self.pos.y, 0.0)
Пример #16
0
 def OnFrontRender(self):
     if not self.visible: return
     cad.DrawColor(cad.Color(255, 255, 255))
     wx.GetApp().GetViewport().DrawWindow(self.box_chosen, False)
Пример #17
0
 def SetColor(self, c):
     col = copy.copy(c)
     if c == cad.Color(255, 255, 255): col = cad.Color(0, 0, 0)
     pen = wx.Pen(col.ref(), self.scale + 0.99)
     self.GetDC().SetPen(pen)