def extrude(self,caps=True):
     """ extrudes a tube along the NURBS curve """
     self.curve2 = mc.duplicate(self.origCurve, name=self.origCurve+"_copy")[0]
     # select the first CV of the path (curve)
     mc.select("%s.cv[0]"%self.curve2,replace=True)
     # figure out where to put the circle and which way to point it
     circleCenter = mc.xform(q=True,ws=True,t=True)
     circleNormal = mc.pointOnCurve(self.curve2, parameter=0, tangent=True)
     # create a circle to use for extrusion
     circle = mc.circle(radius=self.radius, center=circleCenter, normal=circleNormal)[0]
     # extrude!
     extrusion = mc.extrude( circle, self.curve2, n="nurbsTubeTrace", extrudeType=2, range=True )[0]
     self.traceBits = [extrusion, self.curve2, self.origCurve, circle]
     if caps:
         # select the first isoparm
         mc.select(extrusion+".v[%f]"%cu.findParamAtArcPercent( self.origCurve, 0.0))
         # create planar surface
         begCap = mc.planarSrf(n="cap1")[0]
         # select the last isoparm
         mc.select(extrusion+".v[%f]"%cu.findParamAtArcPercent( self.origCurve, 1.0))
         # create planar surface
         endCap = mc.planarSrf(n="cap2")[0]
         mc.setKeyframe( endCap+".visibility", t=self.timeSpan[1]-1, v=0.0 )
         mc.setKeyframe( endCap+".visibility", t=self.timeSpan[1], v=1.0 )
         # add the caps to the traceBits list
         self.traceBits.extend([begCap,endCap])
     return extrusion
Esempio n. 2
0
def makeLeaves( turtle, _leafNum ):
    tpos = cmds.getAttr( 'curve' + str(turtle.curveNum - 1) + '.cv[1]')
    tpos = tpos[0]  
    for i in range (_leafNum):
        leafName = 'leaf' + str(turtle.curveNum - 1) + '_' + str(i)
        cmds.planarSrf( 'lCurve' + str(turtle.curveNum - 1) + '_' + str(i), name = leafName , d=1, ch = False)     #create plane from curve
        #set pivot to ending point of leaf branch
        cmds.setAttr (leafName + '.scalePivot'  , tpos[0], tpos[1], tpos[2], type = 'double3' )
        cmds.setAttr (leafName + '.rotatePivot' , tpos[0], tpos[1], tpos[2], type = 'double3' )
        #place leaf
        cmds.rotate(0, 0, random.randint(-85, 85), leafName, os = True, r = True )  
        cmds.rotate(0, random.randint(-15, 15), 0, leafName, os = True, r = True ) 
        cmds.rotate(random.randint(-40, 40), 0, 0, leafName, os = True, r = True ) 
Esempio n. 3
0
    def makeWords(self, mostCommon, font='Comic Sans MS'):
        """ Function to make the text curves of the three most common words
        
        Function to go through the list of the most common used words 
        and order them from greatest to least, the most common starting on top. 
        """

        for i in range(0, len(mostCommon)):
            curves = mc.textCurves(n="word{0}".format(1),
                                   f=font,
                                   t=mostCommon[i][0],
                                   ch=True)
            mc.setAttr(curves[0] + ".translateY", (len(mostCommon) - i) * 0.5)
            mc.select(ne=True)
            mc.planarSrf(n="Trim Char {0}".format(curves), ko=False, d=1, po=1)
Esempio n. 4
0
def Lab_coordinates_system_representation():
    """
    Creates a *CIE L\\*a\\*b\\** coordinates system representation.

    Returns
    -------
    bool
        Definition success.
    """

    group = cmds.createNode('transform')

    cube = cmds.polyCube(w=600, h=100, d=600, sx=12, sy=2, sz=12, ch=False)[0]
    set_attributes({
        '{0}.translateY'.format(cube): 50,
        '{0}.overrideEnabled'.format(cube): True,
        '{0}.overrideDisplayType'.format(cube): 2,
        '{0}.overrideShading'.format(cube): False
    })
    cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True)
    cmds.select(['{0}.f[0:167]'.format(cube), '{0}.f[336:359]'.format(cube)])
    cmds.delete()

    cmds.nurbsToPolygonsPref(polyType=1, chordHeightRatio=0.975)

    for label, position, name in (('-a*', (-350, 0),
                                   'minus_a'), ('+a*', (350, 0), 'plus_a'),
                                  ('-b*', (0, 350),
                                   'minus_b'), ('+b*', (0, -350), 'plus_b')):
        curves = cmds.listRelatives(
            cmds.textCurves(f='Arial Black Bold', t=label)[0])
        mesh = cmds.polyUnite(
            *[cmds.planarSrf(x, ch=False, o=True, po=1) for x in curves],
            ch=False)[0]
        cmds.xform(mesh, cp=True)
        cmds.xform(mesh, translation=(0, 0, 0), absolute=True)
        cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True)
        cmds.select(mesh)
        cmds.polyColorPerVertex(rgb=(0, 0, 0), cdo=True)
        set_attributes({
            '{0}.translateX'.format(mesh): position[0],
            '{0}.translateZ'.format(mesh): position[1],
            '{0}.rotateX'.format(mesh): -90,
            '{0}.scaleX'.format(mesh): 50,
            '{0}.scaleY'.format(mesh): 50,
            '{0}.scaleY'.format(mesh): 50,
            '{0}.overrideEnabled'.format(mesh): True,
            '{0}.overrideDisplayType'.format(mesh): 2
        })
        cmds.delete(cmds.listRelatives(curves, parent=True))
        cmds.makeIdentity(mesh, apply=True, t=True, r=True, s=True)
        mesh = cmds.rename(mesh, name)
        cmds.parent(mesh, group)

    cube = cmds.rename(cube, 'grid')
    cmds.parent(cube, group)
    cmds.rename(group, 'Lab_coordinates_system_representation')

    return True
Esempio n. 5
0
def Lab_coordinates_system_representation():
    """
    Creates a *CIE L\\*a\\*b\\** coordinates system representation.

    Returns
    -------
    bool
        Definition success.
    """

    group = cmds.createNode('transform')

    cube = cmds.polyCube(w=600, h=100, d=600, sx=12, sy=2, sz=12, ch=False)[0]
    set_attributes({'{0}.translateY'.format(cube): 50,
                    '{0}.overrideEnabled'.format(cube): True,
                    '{0}.overrideDisplayType'.format(cube): 2,
                    '{0}.overrideShading'.format(cube): False})
    cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True)
    cmds.select(['{0}.f[0:167]'.format(cube), '{0}.f[336:359]'.format(cube)])
    cmds.delete()

    cmds.nurbsToPolygonsPref(polyType=1, chordHeightRatio=0.975)

    for label, position, name in (('-a*', (-350, 0), 'minus_a'),
                                  ('+a*', (350, 0), 'plus_a'),
                                  ('-b*', (0, 350), 'minus_b'),
                                  ('+b*', (0, -350), 'plus_b')):
        curves = cmds.listRelatives(
            cmds.textCurves(f='Arial Black Bold', t=label)[0])
        mesh = cmds.polyUnite(*[cmds.planarSrf(x,
                                               ch=False,
                                               o=True,
                                               po=1)
                                for x in curves],
                              ch=False)[0]
        cmds.xform(mesh, cp=True)
        cmds.xform(mesh, translation=(0, 0, 0), absolute=True)
        cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True)
        cmds.select(mesh)
        cmds.polyColorPerVertex(rgb=(0, 0, 0), cdo=True)
        set_attributes({'{0}.translateX'.format(mesh): position[0],
                        '{0}.translateZ'.format(mesh): position[1],
                        '{0}.rotateX'.format(mesh): -90,
                        '{0}.scaleX'.format(mesh): 50,
                        '{0}.scaleY'.format(mesh): 50,
                        '{0}.scaleY'.format(mesh): 50,
                        '{0}.overrideEnabled'.format(mesh): True,
                        '{0}.overrideDisplayType'.format(mesh): 2})
        cmds.delete(cmds.listRelatives(curves, parent=True))
        cmds.makeIdentity(mesh, apply=True, t=True, r=True, s=True)
        mesh = cmds.rename(mesh, name)
        cmds.parent(mesh, group)

    cube = cmds.rename(cube, 'grid')
    cmds.parent(cube, group)
    cmds.rename(group, 'Lab_coordinates_system_representation')

    return True
Esempio n. 6
0
def text(t = "foo", font="Droid Sans", hipoly = False, cleanup = True):
    #note: hipoly mode seems to generate a couple weird extra vertices in the final output.
    obj1 = mc.textCurves( f=font,t=t)
    obj2 = mc.planarSrf(obj1)
    if hipoly:
        obj3 = nurbsToPoly()
    else:
        obj3 = mel.eval("nurbsToPoly -mnd 1  -ch 1 -f 1 -pt 1 -pc 500 -chr 0.9 -ft 0.7787 -mel 1 -d 0.196 -ut 1 -un 3 -vt 1 -vn 3 -uch 0 -ucr 0 -cht 0.01 -es 0 -ntr 0 -mrt 0 -uss 1 \"" + obj2[0] + "\";")
    if cleanup:
        d([obj1,obj2])
        mc.xform(obj3[0], cp=True)
    return obj3
Esempio n. 7
0
def text(t="foo", font="Droid Sans", hipoly=False, cleanup=True):
    #note: hipoly mode seems to generate a couple weird extra vertices in the final output.
    obj1 = mc.textCurves(f=font, t=t)
    obj2 = mc.planarSrf(obj1)
    if hipoly:
        obj3 = nurbsToPoly()
    else:
        obj3 = mel.eval(
            "nurbsToPoly -mnd 1  -ch 1 -f 1 -pt 1 -pc 500 -chr 0.9 -ft 0.7787 -mel 1 -d 0.196 -ut 1 -un 3 -vt 1 -vn 3 -uch 0 -ucr 0 -cht 0.01 -es 0 -ntr 0 -mrt 0 -uss 1 \""
            + obj2[0] + "\";")
    if cleanup:
        d([obj1, obj2])
        mc.xform(obj3[0], cp=True)
    return obj3
Esempio n. 8
0
    def triangulate(self, outType="curves", timer=0):
        "Makes all calculation. You can specify the output type (curves or faces) and if you want to set a timer to see consumed time in the operation"

        #check if you want to display time consumed for the operation:
        if timer: currTime = datetime.datetime.now()

        #create an empty triangle list
        triangles = []
        #and en empty list to store vertexes in order
        vertex = []

        ##we need to start with a supertriangle which encompasses all the points
        ##this is done by getting the minimum and maximum bounds of all points
        ##and by adding a triangle to the triangles list which is a tad bigger than this bounds
        #copy the vertices list
        vs = self.vertices
        vertex.extend(vs)
        #make a series of operations to find minimum and maximum x and y values
        xmin = vs[0][0]
        ymin = vs[0][1]
        xmax = xmin
        ymax = ymin
        for i in range(self.numPoints):
            if vs[i][0] < xmin: xmin = vs[i][0]
            if vs[i][0] > xmax: xmax = vs[i][0]
            if vs[i][1] < ymin: ymin = vs[i][1]
            if vs[i][1] > ymax: ymax = vs[i][1]
        #get min and max distances
        dx = xmax - xmin
        dy = ymax - ymin
        if dx > dy:
            dmax = dx
        else:
            dmax = dy
        #get mid points of these distances
        xmid = (xmax + xmin) / 2
        ymid = (ymax + ymin) / 2

        #calculate the coordinates of the vertices of the supertriangle
        #and add them to the end of the vertex list
        #and add this triangle to the triangles list (it is the first)
        v1x = xmid - 2 * dmax
        v1y = ymid - dmax
        vertex.append([v1x, v1y])
        v2x = xmid
        v2y = ymid + 2 * dmax
        vertex.append([v2x, v2y])
        v3x = xmid + 2 * dmax
        v3y = ymid - dmax
        vertex.append([v3x, v3y])
        triangles.append(
            [self.numPoints, self.numPoints + 1, self.numPoints + 2])

        ##having already one triangle in the triangles list, we can start adding points
        ##and re-triangulate everytime we need

        #progress window > initialize before the loop
        cmds.progressWindow(
            title=
            'Creating Delaunay regions...',  #here you input your message for the progress window/can be anything
            minValue=0,
            maxValue=self.
            numPoints,  # this is imporant: when will the progress be 100%?
            status='Points left: %d' %
            self.numPoints,  # here is some status message /anything you want
            isInterruptable=True)

        #Include each point one at a time into the existing triangulations
        for i in range(len(vertex)):
            #if i is more than the original number of points, stop loop
            #cos then it is a vertex of the supertriangle, and we don't need to calculate them
            if i >= self.numPoints: break
            #get current point i coordinates
            p = vertex[i]
            #Set up the edge buffer.
            #If the point (x,y) lies inside the circumcircle formed by each triangle,
            #then the three edges of that triangle are added to the edge buffer.
            edges = []

            #create a copy of the triangles list to loop through
            tcopy = []
            tcopy.extend(triangles)
            #loop through the triangles to check the points
            for t in tcopy:
                #if the triangle is composed by the vertex in question (i), skip
                if i in t: continue
                #convert the triangle vertices to a list of coordinates
                tri = [[vertex[k][0], vertex[k][1]] for k in t]
                #check if the point i is in the circle formed by this triangle
                ic = self.inCircle(point=[p[0], p[1]], triangle=tri)
                if ic:
                    #in case ic == true:
                    #store the edges in the edges list
                    edges.append([t[0], t[1]])
                    edges.append([t[1], t[2]])
                    edges.append([t[2], t[0]])
                    #remove triangle from triangle list
                    triangles.remove(t)

            #delete all duplicate edges from the edge buffer
            #this leaves the edges of the enclosing polygon only
            edges = removeDuplicates(edges)

            #add to the triangle list all triangles formed between the point
            #and the edges of the enclosing polygon (from the edge buffer
            for j in range(len(edges)):
                v1 = edges[j][0]
                v2 = edges[j][1]
                v3 = i
                triangles.append([v1, v2, v3])

            #update progress window
            if cmds.progressWindow(query=True, isCancelled=True): break
            cmds.progressWindow(edit=True,
                                step=1,
                                status=('Points left: %d' %
                                        (self.numPoints - i)))

        #end loop for vertices

        # FINAL STEP
        # now draw the triangles defined in the triangels list

        for t in triangles:
            print(t)
            #check if this triangle does not belong to the supertriangle,
            #if it does, jump
            if t[0] > self.numPoints - 1 or t[1] > self.numPoints - 1 or t[
                    2] > self.numPoints - 1:
                continue
            #get coordinates of the triangle t
            v1 = vertex[t[0]]
            v2 = vertex[t[1]]
            v3 = vertex[t[2]]
            #see if all coordinates contain the Z value, if not, add z=0
            if len(v1) == 2: v1.append(0)
            if len(v2) == 2: v2.append(0)
            if len(v3) == 2: v3.append(0)
            #draw the curve
            crv = cmds.curve(p=[v1, v2, v3], d=1)
            crv = cmds.closeCurve(crv, rpo=1)
            #if outType is specified as "faces", draw the face
            if outType == "faces": cmds.planarSrf(crv)
            #to see in real time, uncomment the line below (increase operation time by circa 5 times)
            #cmds.refresh(cv=1)

        #end progress window
        cmds.progressWindow(endProgress=1)

        #feedback
        print("Delaunay triangulations created successfully!")
        print(">> %d points" % self.numPoints)
        print(">> %d triangles" % len(triangles))
        #check if you want to see time consumed
        if timer:
            delta_t = datetime.datetime.now() - currTime
            print(">> Time consumed: %s" % str(delta_t))
Esempio n. 9
0
	if len(sortedKeyFrameList) > 1:

		for keyFrame in sortedKeyFrameList:
			pointList.append(allParticleDictionary[curveParticleId][keyFrame])
					
		curveName = "partiCurve" + str(curveParticleId)
		curveObj = mc.curve(name=curveName, p=pointList)
			
		
		#For every locator we create, make a bubble and attach that to the locator in worldspace and parent in underneath
        getCurvLen = mc.arclen(curveObj)
        makeCvrLenInt = math.ceil(getCurvLen*.5)#reduces the amount of spans the curve has, this is useful on very long extrusions 
        
        
        makeCircle = mc.circle(n="newCircle",d=1, s=12)
        aCircle = mc.planarSrf(makeCircle[0], n="extruTube", ch=1, d=1, ko=0, rn=0, po=1, nds=3)
        getTesInfo = mc.listConnections(aCircle[1], t="nurbsTessellate")
        mc.setAttr(getTesInfo[0] + ".polygonCount", 1)
        mc.setAttr(getTesInfo[0] + ".polygonType", 1)
        mc.setAttr(getTesInfo[0] + ".format", 0)
        
        
        getCurveCVPos = mc.xform(curveObj + ".cv[0]", ws=True, q=True, translation=True)
        mc.xform(makeCircle[0], ws=True, t=(getCurveCVPos[0], getCurveCVPos[1], getCurveCVPos[2]),ro=(90, 0, 0))#use "ro" to orient the circle to the curve if your extrusion is black
        
        tubes = mc.polyExtrudeFacet(aCircle[0] + ".f[0]", inc=curveObj, d=makeCvrLenInt)
        subCurveCreate = mc.createNode("subCurve", n="subCurve_" + curveObj)
        curveShape = mc.listRelatives(curveObj, s=True)
        
        mc.setAttr(subCurveCreate + ".relative", 1)
        mc.connectAttr(curveShape[0] + ".worldSpace", subCurveCreate + ".inputCurve", f=True)
Esempio n. 10
0
	def triangulate(self, outType="curves", timer=0):
		"Makes all calculation. You can specify the output type (curves or faces) and if you want to set a timer to see consumed time in the operation"
		
		#check if you want to display time consumed for the operation:
		if timer: currTime = datetime.datetime.now()
		
		#create an empty triangle list
		triangles = []
		#and en empty list to store vertexes in order
		vertex = []
		
		##we need to start with a supertriangle which encompasses all the points
		##this is done by getting the minimum and maximum bounds of all points
		##and by adding a triangle to the triangles list which is a tad bigger than this bounds
		#copy the vertices list
		vs = self.vertices
		vertex.extend(vs)
		#make a series of operations to find minimum and maximum x and y values
		xmin = vs[0][0]
		ymin = vs[0][1]
		xmax = xmin
		ymax = ymin
		for i in range(self.numPoints):
			if vs[i][0] < xmin: xmin = vs[i][0]
			if vs[i][0] > xmax: xmax = vs[i][0]
			if vs[i][1] < ymin: ymin = vs[i][1]
			if vs[i][1] > ymax: ymax = vs[i][1] 
		#get min and max distances
		dx = xmax-xmin
		dy = ymax-ymin
		if dx > dy:
			dmax = dx
		else:
			dmax = dy
		#get mid points of these distances
		xmid = (xmax+xmin)/2
		ymid = (ymax+ymin)/2
		
		#calculate the coordinates of the vertices of the supertriangle
		#and add them to the end of the vertex list
		#and add this triangle to the triangles list (it is the first)
		v1x = xmid - 2*dmax
		v1y = ymid - dmax
		vertex.append([v1x, v1y])
		v2x = xmid
		v2y = ymid + 2*dmax
		vertex.append([v2x, v2y])
		v3x = xmid + 2*dmax
		v3y = ymid - dmax
		vertex.append([v3x, v3y])		
		triangles.append([self.numPoints,self.numPoints+1,self.numPoints+2])
		
		##having already one triangle in the triangles list, we can start adding points
		##and re-triangulate everytime we need
		
		#progress window > initialize before the loop
		cmds.progressWindow(title='Creating Delaunay regions...', #here you input your message for the progress window/can be anything
							minValue=0,
							maxValue=self.numPoints,    # this is imporant: when will the progress be 100%?
							status='Points left: %d' % self.numPoints,  # here is some status message /anything you want
							isInterruptable=True )
		
		#Include each point one at a time into the existing triangulations
		for i in range(len(vertex)):
			#if i is more than the original number of points, stop loop 
			#cos then it is a vertex of the supertriangle, and we don't need to calculate them
			if i >= self.numPoints: break
			#get current point i coordinates
			p = vertex[i]
			#Set up the edge buffer.
			#If the point (x,y) lies inside the circumcircle formed by each triangle, 
			#then the three edges of that triangle are added to the edge buffer.
			edges = []
			
			#create a copy of the triangles list to loop through
			tcopy = []
			tcopy.extend(triangles)
			#loop through the triangles to check the points
			for t in tcopy:
				#if the triangle is composed by the vertex in question (i), skip
				if i in t: continue
				#convert the triangle vertices to a list of coordinates
				tri=[ [vertex[k][0], vertex[k][1]] for k in t ]
				#check if the point i is in the circle formed by this triangle
				ic = self.inCircle(point=[p[0], p[1]], triangle=tri)
				if ic:
					#in case ic == true:
					#store the edges in the edges list
					edges.append([t[0], t[1]])
					edges.append([t[1], t[2]])
					edges.append([t[2], t[0]])
					#remove triangle from triangle list
					triangles.remove(t)
			
			#delete all duplicate edges from the edge buffer
			#this leaves the edges of the enclosing polygon only
			edges = removeDuplicates(edges)

			#add to the triangle list all triangles formed between the point
			#and the edges of the enclosing polygon (from the edge buffer
			for j in range(len(edges)):
				v1 = edges[j][0]
				v2 = edges[j][1]
				v3 = i
				triangles.append([v1,v2,v3])
			
			#update progress window
			if cmds.progressWindow( query=True, isCancelled=True ) : break
			cmds.progressWindow( edit=True, step=1, status=('Points left: %d' % (self.numPoints-i)) ) 
			
		#end loop for vertices
		
		###FINAL STEP
		#now draw the triangles defined in the triangels list
		for t in triangles:
			#check if this triangle does not belong to the supertriangle,
			#if it does, jump
			if t[0] > self.numPoints-1 or t[1] > self.numPoints-1 or t[2] > self.numPoints-1: continue
			#get coordinates of the triangle t
			v1 = vertex[t[0]]
			v2 = vertex[t[1]]
			v3 = vertex[t[2]]
			#see if all coordinates contain the Z value, if not, add z=0
			if len(v1)==2: v1.append(0)
			if len(v2)==2: v2.append(0)
			if len(v3)==2: v3.append(0)
			#draw the curve
			crv = cmds.curve(p=[v1,v2,v3], d=1)
			crv = cmds.closeCurve(crv, rpo=1)
			#if outType is specified as "faces", draw the face
			if outType == "faces": cmds.planarSrf(crv)
			#to see in real time, uncomment the line below (increase operation time by circa 5 times)
			#cmds.refresh(cv=1)
		
		#end progress window
		cmds.progressWindow(endProgress=1)
		
		#feedback
		print "Delaunay triangulations created successfully!"
		print ">> %d points" % self.numPoints
		print ">> %d triangles" % len(triangles)
		#check if you want to see time consumed
		if timer: 
			delta_t = datetime.datetime.now() - currTime 
			print ">> Time consumed: %s" % str(delta_t)
Esempio n. 11
0
shadingGroupName = shaderName + 'SG'
mc.shadingNode("surfaceShader", asShader=True, name=shaderName)
mc.setAttr(shaderName + ".outColor", 1, 1, 1, type="double3")
mc.sets(renderable=True, empty=1, noSurfaceShader=True, name=shadingGroupName)
mc.defaultNavigation(source=shaderName,
                     destination=shadingGroupName,
                     connectToExisting=1)

for item in shotList:
    shotCurveName = "shotCurve" + item
    shotCurve = mc.textCurves(name=shotCurveName,
                              ch=0,
                              f="Arial",
                              t="sc" + item)
    shotNumberName = "sc" + item
    shotNumber = mc.planarSrf(name=shotNumberName, polygon=3)
    ##mc.setAttr(shotNumberName + ".scale", 0.08, 0.08, 0.08, type="double3")
    mc.sets("sc" + item, forceElement=shadingGroupName, e=1)
    mc.delete(shotCurveName + "Shape")
    mc.setKeyframe(value=0, t=i, attribute="visibility")
    i += 1
    mc.setKeyframe(value=1, t=i, attribute="visibility")
    mc.setKeyframe(value=0, t=i + 1, attribute="visibility")

## clean / delete all attribute renderman
import maya.cmds as mc

selectionList = mc.ls("*rock*Shape*")  ## revoir la selection !!
for item in selectionList:
    if mc.objExists(item + ".rmanCCs"):
        mc.deleteAttr(item + ".rmanCCs")
Esempio n. 12
0
            pointList.append(allParticleDictionary[curveParticleId][keyFrame])

        curveName = "partiCurve" + str(curveParticleId)
        curveObj = mc.curve(name=curveName, p=pointList)

        #For every locator we create, make a bubble and attach that to the locator in worldspace and parent in underneath
    getCurvLen = mc.arclen(curveObj)
    makeCvrLenInt = math.ceil(
        getCurvLen * .5
    )  #reduces the amount of spans the curve has, this is useful on very long extrusions

    makeCircle = mc.circle(n="newCircle", d=1, s=12)
    aCircle = mc.planarSrf(makeCircle[0],
                           n="extruTube",
                           ch=1,
                           d=1,
                           ko=0,
                           rn=0,
                           po=1,
                           nds=3)
    getTesInfo = mc.listConnections(aCircle[1], t="nurbsTessellate")
    mc.setAttr(getTesInfo[0] + ".polygonCount", 1)
    mc.setAttr(getTesInfo[0] + ".polygonType", 1)
    mc.setAttr(getTesInfo[0] + ".format", 0)

    getCurveCVPos = mc.xform(curveObj + ".cv[0]",
                             ws=True,
                             q=True,
                             translation=True)
    mc.xform(
        makeCircle[0],
        ws=True,
Esempio n. 13
0
def fMImport_Retopo(arg):

    path = mc.textField(
        'fMtextField',
        q=True,
        fi=True,
    )
    if path.find('.obj') < 0:
        mc.error('select OBJ mesh')
    else:
        belist = mc.ls(type="transform")
        test = mc.file(path,
                       i=True,
                       type="OBJ",
                       ra=True,
                       mergeNamespacesOnClash=True,
                       namespace="OrigFlatten",
                       options="mo=1,lo=0")
        aflist = mc.ls(type="transform")
        #seperate pieces
        origFMlist_root = list(set(aflist) - set(belist))
        origFMlist_temp = []
        origFMlist = []
        for fm in origFMlist_root:
            mc.select(fm)
            mc.SeparatePolygon()
            mc.DeleteHistory()
            sep_list = []
            sep_templist = mc.ls(sl=True)
            for sep in sep_templist:
                mc.select(sep)
                sep_list.append(mc.rename('OrigFlatten_01'))
            mc.pickWalk(direction='up')
            mc.Ungroup()
            origFMlist_temp.append(sep_list)
        for x in origFMlist_temp:
            for y in x:
                origFMlist.append(y)

        #create set or add into existing one original flatten mesh
        if mc.objExists('OrigFlatMeshes_set'):
            mc.sets(origFMlist, forceElement='OrigFlatMeshes_set')
        else:
            newSet1 = cmds.sets(name='OrigFlatMeshes_set')
            mc.sets(origFMlist, forceElement='OrigFlatMeshes_set')
        #polyRetopo imported meshes
        pRlist = []
        for u in origFMlist:
            mc.select(u)
            mc.ConvertSelectionToEdgePerimeter(u)
            mc.planarSrf(
                n='Surface' +
                str(u))  # reikia variable pavadinima ivesti jog sukurtu
            mc.nurbsToPoly(ch=True,
                           f=0,
                           pt=1,
                           pc=1000,
                           chr=0.9,
                           ft=0.01,
                           mel=0.001,
                           d=0.1,
                           n='nurbsToPoly' + str(u))
            chpoly = mc.polyEvaluate(shell=True)
            #check if mesh has several pieces
            if chpoly > 1:
                mc.SeparatePolygon()
            mc.DeleteHistory()
            chlist = mc.ls(sl=True)
            #check if mesh is in the group
            if len(chlist) > 1:
                mc.pickWalk(direction='up')
                mc.Ungroup()
            o = mc.ls(sl=True)
            if len(o) == 1:
                mc.polyRetopo('nurbsToPoly' + str(u))
                mc.rename('Retopo_mesh_01')
                #add new polyRetopo mesh to list
                pRsl = mc.ls(sl=True)
                pRlist.append(pRsl)
            else:
                for y in o:
                    mc.select(y, r=True)
                    mc.polyRetopo(y)
                    mc.sets(fe='initialShadingGroup')
                    mc.rename('Retopo_mesh_01')
                    #add new polyRetopo mesh to list
                    pRsl = mc.ls(sl=True)
                    pRlist.append(pRsl)

            sfrlist = mc.select('Surface' + str(u))
            mc.Delete(sfrlist)
            #hide Original mesh accordingly if check box is on or off
            mc.select('OrigFlatMeshes_set')
            listObjectsInSet = mc.ls(sl=True)
            for objOnSet in listObjectsInSet:
                visValue = mc.getAttr(str(objOnSet) + '.visibility')
                checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True)
                if visValue is False or checkBoxStatus is True:
                    mc.setAttr((objOnSet + '.visibility'), 0)
        #transfer uvs from Marvelous mesh to new polyRetopo meshes
        iterpRlist = iter(pRlist)
        for fm in origFMlist:
            mc.select(fm)
            mc.select(next(iterpRlist), add=True)
            mc.transferAttributes(transferPositions=0,
                                  transferNormals=0,
                                  transferUVs=2,
                                  transferColors=0,
                                  sampleSpace=0,
                                  sourceUvSpace="map1",
                                  targetUvSpace="map1",
                                  searchMethod=3,
                                  flipUVs=0,
                                  colorBorders=1)
        #adapt faceCount of new created polyRetopo meshes
        mc.select(d=True)
        for pRmesh in pRlist:
            mc.select(pRmesh, add=True)
        adaptPoly()
Esempio n. 14
0
def m_polyretopo():

    selected = mc.ls(sl=True)
    pRlist = []
    #create set or add into existing one original flatten mesh
    if mc.objExists('OrigFlatMeshes_set'):
        mc.sets(selected, forceElement='OrigFlatMeshes_set')
    else:
        newSet1 = cmds.sets(name='OrigFlatMeshes_set')
        mc.sets(selected, forceElement='OrigFlatMeshes_set')
    for u in selected:
        mc.select(u)
        mc.ConvertSelectionToEdgePerimeter(u)
        mc.planarSrf(n='Surface' +
                     str(u))  # reikia variable pavadinima ivesti jog sukurtu
        mc.nurbsToPoly(ch=True,
                       f=0,
                       pt=1,
                       pc=1000,
                       chr=0.9,
                       ft=0.01,
                       mel=0.001,
                       d=0.1,
                       n='nurbsToPoly' + str(u))
        chpoly = mc.polyEvaluate(shell=True)
        #check if mesh has several pieces
        if chpoly > 1:
            mc.SeparatePolygon()
        mc.DeleteHistory()
        chlist = mc.ls(sl=True)
        #check if mesh is in the group
        if len(chlist) > 1:
            mc.pickWalk(direction='up')
            mc.Ungroup()
        o = mc.ls(sl=True)
        if len(o) == 1:
            mc.polyRetopo('nurbsToPoly' + str(u))
            mc.rename('Retopo_mesh_01')
            #add new polyRetopo mesh to list
            pRsl = mc.ls(sl=True)
            pRlist.append(pRsl)
        else:
            for y in o:
                mc.select(y, r=True)
                mc.polyRetopo(y)
                mc.sets(fe='initialShadingGroup')
                mc.rename('Retopo_mesh_01')
                #add new polyRetopo mesh to list
                pRsl = mc.ls(sl=True)
                pRlist.append(pRsl)

        sfrlist = mc.select('Surface' + str(u))
        mc.Delete(sfrlist)
        #hide Original mesh accordingly if check box is on or off
        mc.select('OrigFlatMeshes_set')
        listObjectsInSet = mc.ls(sl=True)
        for objOnSet in listObjectsInSet:
            visValue = mc.getAttr(str(objOnSet) + '.visibility')
            checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True)
            if visValue is False or checkBoxStatus is True:
                mc.setAttr((objOnSet + '.visibility'), 0)
import maya.cmds as cmds
import sys


cmds.textCurves(t='Hello 3D World', n='text')
cmds.planarSrf(n='text')

print 'Hello 3D Digital Design'
sys.stdout.write('Hello 3D World')