Esempio n. 1
0
def update_mouse():
    global mouseX,screenX,mouseY,screenY,pmouseX,pmouseY,\
           _pmousePressed,mousePressed,mouseMoved,mouseDragged,mouseClicked
    pmouseX = mouseX
    pmouseY = mouseY
    _pmousePressed = mousePressed
    _posInfo = rs.GetCursorPos()
    screenX = _posInfo[1].X
    screenY = _posInfo[1].Y
    client = thisDoc.Views.ActiveView.ActiveViewport.ClientToWorld(_posInfo[3])
    tup = Intersect.Intersection.LinePlane(client,CPLANE)
    if tup[0]:
        ptOnPlane = client.PointAt(tup[1])
        mouseX = ptOnPlane.X
        mouseY = ptOnPlane.Y
    else:
        mouseX = _posInfo[0].X
        mouseY = _posInfo[0].Y
    #? returned mouseX,Y is based on world coord but ellipse,rect...function is based on CPLANE so
    mouseX -= CPLANE.OriginX
    mouseY -= CPLANE.OriginY
    mousePressed = isMousePressed()
    mouseMoved = pmouseX != mouseX or pmouseY != mouseY
    mouseDragged = mouseMoved and mousePressed
    mouseClicked = _pmousePressed and not mousePressed
Esempio n. 2
0
def GetPointDynamicDrawFuncHide(sender, args):

    obj_all = rs.VisibleObjects()
    rs.HideObjects(obj_all)

    cursPos = rs.GetCursorPos()
    viewSize = rs.ViewSize()
    stepSize = int(viewSize[1] / _NUM_LAYER)

    obj_Layer1 = 'Layer: 000001 Wall1'
    obj_Layer2 = 'Layer: 000002 Wall1'
    settings = Rhino.DocObjects.ObjectEnumeratorSettings()
    settings.HiddenObjects = True

    settings.NameFilter = obj_Layer1
    ids_L1 = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]

    settings.NameFilter = obj_Layer2
    ids_L2 = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]

    z_L1 = rs.BoundingBox(ids_L1[0])[0][2]
    z_L2 = rs.BoundingBox(ids_L2[0])[0][2]

    zVal = viewSize[1] - cursPos[3][1]

    z_level = int(zVal / stepSize)

    segmentList = ['Wall',
                   'DenseInfill',
                   'SparseInfill',
                   'Brim',
                   'Skirt',
                   'Support']

    zero_str = '000000'

    settings = ObjectEnumeratorSettings()
    settings.HiddenObjects = True

    for segment in segmentList:
        i = 0
        while 1:
            i += 1
            obj_LayerZ = str('Layer: ' + zero_str[:-len(str(z_level))] + str(z_level) + ' ' + segment + str(i))
            try:
                settings.NameFilter = obj_LayerZ
                ids_LZ = [rhobj.Id for rhobj in scriptcontext.doc.Objects.GetObjectList(settings)]
                if len(ids_LZ) == 0:
                    break
                # rs.SelectObject(ids_LZ)
                rs.ShowObject(ids_LZ)

            except:
                print 'not found'

    args.Display.DrawDot(args.CurrentPoint, 'Layer ' + str(z_level) + ' - Distance ' + str(z_L2 - z_L1) + ' mm')
    Rhino.Display.RhinoView.Redraw(scriptcontext.doc.Views.ActiveView)
    Rhino.RhinoApp.Wait()
Esempio n. 3
0
def update_mouse():
    _ghl.pmouseX = _ghl.mouseX
    _ghl.pmouseY = _ghl.mouseY
    _pmousePressed = _ghl.mousePressed
    _posInfo = rs.GetCursorPos()
    _ghl.mouseX = _posInfo[0].X
    _ghl.screenX = _posInfo[1].X
    _ghl.mouseY = _posInfo[0].Y
    _ghl.screenY = _posInfo[1].Y
    client = VIEWPORT.ClientToWorld(_posInfo[3])
    tup = Intersect.Intersection.LinePlane(client,_ghl.CPLANE)
    if tup[0]:
        ptOnPlane = client.PointAt(tup[1])
        _ghl.mouseX = ptOnPlane.X
        _ghl.mouseY = ptOnPlane.Y
    _ghl.mousePressed = isMousePressed()
    _ghl.mouseMoved = _ghl.pmouseX != _ghl.mouseX \
                 or _ghl.pmouseY != _ghl.mouseY
    _ghl.mouseDragged = _ghl.mouseMoved and _ghl.mousePressed
    _ghl.mouseClicked = _pmousePressed and not _ghl.mousePressed
Esempio n. 4
0
STYLESTACK = []
_SHAPESTACK = []
_CPLANESTACK = []
CPLANE = Plane.WorldXY
AUTO_DISPLAY = True
GEOMETRY_OUTPUT = True
COLOR_OUTPUT = False
GeoOut = DataTree[object]()
ColorOut = DataTree[Color]()
INFO = Info()
VIEWPORT = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport
## general setting that persist over different instacnes
TORLERENCE = Rhino.RhinoDoc.ActiveDoc.PageAbsoluteTolerance
thisDoc = Rhino.RhinoDoc.ActiveDoc
# mouse variable that all instances share(not actually shared, but should be diffcult to notice)
_posInfo = rs.GetCursorPos()
mouseX = _posInfo[0].X
mouseY = _posInfo[0].Y
pmouseX = mouseX
pmouseY = mouseY
mousePressed = False
_pmousePressed = False
mouseMoved = False
mouseDragged = False
mouseClicked = False
def update_mouse():
    global mouseX,screenX,mouseY,screenY,pmouseX,pmouseY,\
           _pmousePressed,mousePressed,mouseMoved,mouseDragged,mouseClicked
    pmouseX = mouseX
    pmouseY = mouseY
    _pmousePressed = mousePressed