Ejemplo n.º 1
2
def lcObj_exportObjs(*args, **kwargs):
  ''' Export .obj files from selected geometry, either as one combined file or as individual files per object.  Will recognize and convert poly smooth preview to geometry for export '''
  global prefix
  path = pm.textField(prefix+'_textField_export_path', query=True, text=True)
  objPrefix = pm.textField(prefix+'_textField_prefix', query=True, text=True)
  if objPrefix:
    objPrefix+='_'

  if path:

    sel = pm.ls(sl=True)

    if sel:
      sel = geometry.filterForGeometry(sel)
      print sel

      #undo is the easiest way to work on geometry temporarily
      pm.undoInfo(openChunk=True)

      if pm.checkBox(prefix+'_checkBox_use_smooth', query=True, v=True):
        for obj in sel:
          pm.select(obj)
          #find the objects currently displayed as smooth and create converted poly copies
          if pm.displaySmoothness(q=True, polygonObject=True)[0] == 3:
            pm.mel.performSmoothMeshPreviewToPolygon()

      if pm.checkBox(prefix+'_checkBox_export_indi', query=True, v=True):
        #export objects individually
        for obj in sel:
          pm.select(obj)
          name = str(obj)
          exportString = path+'/'+objPrefix+name+'.obj'
          pm.exportSelected(exportString, force=True, options='groups=1;ptgroups=1;materials=0;smoothing=1;normals=1', type='OBJexport', pr=True, es=True)

      else:
        #export as one object
        pm.select(sel)
        name = ''
        while name == '':
          dialog = pm.promptDialog(title='OBJ Name', message='Enter Name:', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel')
          if dialog == 'OK':
            name = pm.promptDialog(query=True, text=True)
            if name:
              exportString = path+'/'+objPrefix+name+'.obj'
              pm.exportSelected(exportString, force=True, options='groups=1;ptgroups=1;materials=0;smoothing=1;normals=1', type='OBJexport', pr=True, es=True)
            else:
              pm.warning("You didn't type a name for your obj")
          if dialog == 'Cancel':
            break

      pm.undoInfo(closeChunk=True)
      pm.undo()
      pm.select(clear=True)

  else:
    pm.warning('Did you specify a path?')
Ejemplo n.º 2
0
def rtb_shrink_wrap_verts(highresListDropdown, *args, **kwargs):
  ''' '''
  global defaultString
  high = highresListDropdown.getValue()

  if not high == defaultString:

    pm.undoInfo(openChunk=True)

    live = pm.PyNode(high.replace('_high', '_live'))
    liveShape = live.getShape()
    sel = pm.ls(sl=True)
    if sel:
      verts = geometry.getVertsFromSelection(sel)
      if verts and verts[0].nodeType() == 'mesh':
        try:
          geometry.shrinkWrap(verts, liveShape, prefix+'_progress_control')
        except:
          pm.warning('You Should Not See This Error!')
          pm.progressBar(prefix+'_progress_control', edit=True, endProgress=True)
      else:
        pm.warning('No verts to shrink wrap!')
      pm.select(sel, r=True)
      pm.hilite(pm.PyNode(sel[0].split('.')[0]).getParent(), r=True)
      type = geometry.getMeshSelectionType(sel)
      geometry.switchSelectType(type)

      pm.undoInfo(closeChunk=True)

  else:
    pm.warning('Select a mesh from the dropdown list')
def rtb_shrink_wrap_verts(highresListDropdown, *args, **kwargs):
    ''' '''
    global defaultString
    high = highresListDropdown.getValue()

    if not high == defaultString:

        pm.undoInfo(openChunk=True)

        live = pm.PyNode(high.replace('_high', '_live'))
        liveShape = live.getShape()
        sel = pm.ls(sl=True)
        if sel:
            verts = geometry.getVertsFromSelection(sel)
            if verts and verts[0].nodeType() == 'mesh':
                try:
                    geometry.shrinkWrap(verts, liveShape,
                                        prefix + '_progress_control')
                except:
                    pm.warning('You Should Not See This Error!')
                    pm.progressBar(prefix + '_progress_control',
                                   edit=True,
                                   endProgress=True)
            else:
                pm.warning('No verts to shrink wrap!')
            pm.select(sel, r=True)
            pm.hilite(pm.PyNode(sel[0].split('.')[0]).getParent(), r=True)
            type = geometry.getMeshSelectionType(sel)
            geometry.switchSelectType(type)

            pm.undoInfo(closeChunk=True)

    else:
        pm.warning('Select a mesh from the dropdown list')
Ejemplo n.º 4
0
def rtb_setup_live_mesh(highresListDropdown, *args, **kwargs):
  ''' '''
  sel = pm.ls(sl=True)
  geometry.fixNamespaceNames()
  if sel[0] != '':
    root = pm.group(empty=True, name=sel[0]+'_RETOPO')
    live = pm.duplicate(sel[0], name = sel[0]+'_live')[0]
    high = sel[0].rename(sel[0]+'_high')

    pm.makeIdentity([high, live], apply=True, t=1, r=1, s=1, n=0)
    utility.centerPvt([high, live])

    highShape = high.getShape()
    liveShape = live.getShape()

    highShape.overrideEnabled.set(1) #enable display overrides
    highShape.overrideDisplayType.set(2) #set to referenced

    liveShape.overrideEnabled.set(1) #enable display overrides
    liveShape.overrideDisplayType.set(1) #set to template
    liveShape.overrideVisibility.set(0) #set visibility to 0

    pm.select(live)
    pm.makeLive()

    highresListDropdown.addItems([high])
    numItems = highresListDropdown.getNumberOfItems()
    highresListDropdown.setSelect(numItems)

    pm.parent(high, root)
    pm.parent(live, root)

    pm.connectAttr('persp.translate', high.scalePivot)

    rtb_scale_layer_mesh(highresListDropdown)

    rtb_glow(highresListDropdown)
def rtb_setup_live_mesh(highresListDropdown, *args, **kwargs):
    ''' '''
    sel = pm.ls(sl=True)
    geometry.fixNamespaceNames()
    if sel[0] != '':
        root = pm.group(empty=True, name=sel[0] + '_RETOPO')
        live = pm.duplicate(sel[0], name=sel[0] + '_live')[0]
        high = sel[0].rename(sel[0] + '_high')

        pm.makeIdentity([high, live], apply=True, t=1, r=1, s=1, n=0)
        utility.centerPvt([high, live])

        highShape = high.getShape()
        liveShape = live.getShape()

        highShape.overrideEnabled.set(1)  #enable display overrides
        highShape.overrideDisplayType.set(2)  #set to referenced

        liveShape.overrideEnabled.set(1)  #enable display overrides
        liveShape.overrideDisplayType.set(1)  #set to template
        liveShape.overrideVisibility.set(0)  #set visibility to 0

        pm.select(live)
        pm.makeLive()

        highresListDropdown.addItems([high])
        numItems = highresListDropdown.getNumberOfItems()
        highresListDropdown.setSelect(numItems)

        pm.parent(high, root)
        pm.parent(live, root)

        pm.connectAttr('persp.translate', high.scalePivot)

        rtb_scale_layer_mesh(highresListDropdown)

        rtb_glow(highresListDropdown)
Ejemplo n.º 6
0
def lcObj_exportObjs(*args, **kwargs):
    ''' Export .obj files from selected geometry, either as one combined file or as individual files per object.  Will recognize and convert poly smooth preview to geometry for export '''
    global prefix
    path = pm.textField(prefix + '_textField_export_path',
                        query=True,
                        text=True)
    objPrefix = pm.textField(prefix + '_textField_prefix',
                             query=True,
                             text=True)
    if objPrefix:
        objPrefix += '_'

    if path:

        sel = pm.ls(sl=True)

        if sel:
            sel = geometry.filterForGeometry(sel)
            print sel

            #undo is the easiest way to work on geometry temporarily
            pm.undoInfo(openChunk=True)

            if pm.checkBox(prefix + '_checkBox_use_smooth', query=True,
                           v=True):
                for obj in sel:
                    pm.select(obj)
                    #find the objects currently displayed as smooth and create converted poly copies
                    if pm.displaySmoothness(q=True,
                                            polygonObject=True)[0] == 3:
                        pm.mel.performSmoothMeshPreviewToPolygon()

            if pm.checkBox(prefix + '_checkBox_export_indi',
                           query=True,
                           v=True):
                #export objects individually
                for obj in sel:
                    pm.select(obj)
                    name = str(obj)
                    exportString = path + '/' + objPrefix + name + '.obj'
                    pm.exportSelected(
                        exportString,
                        force=True,
                        options=
                        'groups=1;ptgroups=1;materials=0;smoothing=1;normals=1',
                        type='OBJexport',
                        pr=True,
                        es=True)

            else:
                #export as one object
                pm.select(sel)
                name = ''
                while name == '':
                    dialog = pm.promptDialog(title='OBJ Name',
                                             message='Enter Name:',
                                             button=['OK', 'Cancel'],
                                             defaultButton='OK',
                                             cancelButton='Cancel',
                                             dismissString='Cancel')
                    if dialog == 'OK':
                        name = pm.promptDialog(query=True, text=True)
                        if name:
                            exportString = path + '/' + objPrefix + name + '.obj'
                            pm.exportSelected(
                                exportString,
                                force=True,
                                options=
                                'groups=1;ptgroups=1;materials=0;smoothing=1;normals=1',
                                type='OBJexport',
                                pr=True,
                                es=True)
                        else:
                            pm.warning("You didn't type a name for your obj")
                    if dialog == 'Cancel':
                        break

            pm.undoInfo(closeChunk=True)
            pm.undo()
            pm.select(clear=True)

    else:
        pm.warning('Did you specify a path?')