Maya: 第二周 作业

lesson4_从无到有创建新节点


image.png
image.png

绘画比卡丘

tr_node = cmds.createNode('transform', name = 'pikaqiu_control')
for pos_list in pattern_crv_point_pos_list:
    temp_crv = cmds.curve(d=3,p=pos_list)
    temp_crv_shape = cmds.listRelatives(temp_crv, s=True)
    if temp_crv_shape:
        for s in temp_crv_shape:
            cmds.parent(s, tr_node, s=True, add=True)
    cmds.delete(temp_crv)    
cmds.color(tr_node, rgb=(1,1,0))

获取所选择曲线点的坐标信息

import maya.cmds as cmds
sel_crv = cmds.ls(sl=True, tr=True, lon=True)
pattern_crv_point_pos_list = []
for crv in sel_crv:
    crv_all_point = cmds.ls('{}.cv[*]'.format(crv), fl=True)
    crv_point_pos_list = []
    for crv_point in crv_all_point:
        crv_point_pos = cmds.xform(crv_point, q=True, ws=True, t=True) 
        crv_point_pos_list.append(tuple(crv_point_pos))
    pattern_crv_point_pos_list.append(crv_point_pos_list)

皮卡丘曲线信息:

pattern_crv_point_pos_list = [[(-0.098812055257697, 0.0, -0.05640749985373542),
  (-0.10057944520469017, 0.0, -0.04827745147320406),
  (-0.10282167380206217, 0.0, -0.03719820428618953),
  (-0.10414063180051625, 0.0, -0.02268966630319433),
  (-0.10295356960190756, 0.0, -0.008049232520353736),
  (-0.10137082000376262, 0.0, 0.0039532852655786545),
  (-0.0976777376080911, 0.0, 0.015164428252438574),
  (-0.09174242661504761, 0.0, 0.022682488843627006),
  (-0.08738986522014908, 0.0, 0.0240014468420811),
  (-0.08303730382525051, 0.0, 0.023737655242390316),
  (-0.07855284663050653, 0.0, 0.021891114044554537),
  (-0.07156236923869977, 0.0, 0.017142865250119745),
  (-0.06417620444735675, 0.0, 0.009361013059240503),
  (-0.055602977457405035, 0.0, 0.0003920986697525845),
  (-0.04465562607023593, 0.0, -0.015962980511078372),
  (-0.03885221087703786, 0.0, -0.027437915097629134),
  (-0.03495062128529007, 0.0, -0.03878697246941745)],
 [(-0.10268977800221672, 0.0, -0.03521976728850837),
  (-0.09569930061040996, 0.0, -0.03878095388433447),
  (-0.08765365681983989, 0.0, -0.04075939088201563),
  (-0.08013559622865146, 0.0, -0.041550765681088085),
  (-0.06984772384070942, 0.0, -0.040231807682634),
  (-0.061933975849984765, 0.0, -0.03746199588588037),
  (-0.05322885306018765, 0.0, -0.03179047649252768),
  (-0.047350567580311156, 0.0, -0.025379866487459744),
  (-0.04309987793317245, 0.0, -0.019499883254410672)],
 [(0.0412515745311646, 0.0, -0.015587035991861144),
  (0.03476699587505905, 0.0, -0.016744996466165715),
  (0.025503312080622564, 0.0, -0.014197483422695662),
  (0.01392370733757689, 0.0, -0.009334049430616508),
  (0.003270470973974912, 0.0, 0.0027087395021509687),
  (-0.0022877393026869697, 0.0, 0.015909488909222988),
  (-0.00043500254379967573, 0.0, 0.02864705412657319),
  (0.00446440825453218, 0.0, 0.03554130319217785),
  (0.009011051527058559, 0.0, 0.04053493698496698)],
 [(0.04688598522770501, 0.0, -0.2516703951991708),
  (0.05256484640932954, 0.0, -0.2515368089845021),
  (0.060178484852098896, 0.0, -0.24556936263746662),
  (0.06840944533076854, 0.0, -0.23774995018273049),
  (0.07581730976157122, 0.0, -0.22807857162029377),
  (0.08343094820434058, 0.0, -0.2153205828783558),
  (0.08696552469581775, 0.0, -0.2040838075146872)],
 [(-0.2203675859373292, 0.0, -0.2531801802099492),
  (-0.22282254759742076, 0.0, -0.24362305624242833),
  (-0.2243479442359994, 0.0, -0.2317588601645945),
  (-0.22383947868980653, 0.0, -0.2195556870559654),
  (-0.22214459353583027, 0.0, -0.20481018621637193),
  (-0.21909380025867303, 0.0, -0.1910816164691643),
  (-0.21665042338300838, 0.0, -0.18440651872899846)],
 [(0.02099544872435191, 0.0, -0.14162353434784908),
  (0.022358691502773087, 0.0, -0.1548799228306686),
  (0.02531359337660316, 0.0, -0.17615521632224515),
  (0.035064769560242376, 0.0, -0.22284266592876023),
  (0.054567121927520834, 0.0, -0.2715985468469564),
  (0.07200104298311824, 0.0, -0.3017385459600232),
  (0.07791084673077842, 0.0, -0.30853482026983237),
  (0.08352516029105556, 0.0, -0.3091258006445983),
  (0.08470712104058756, 0.0, -0.30380697727170425),
  (0.08588908179011959, 0.0, -0.2899189384647028),
  (0.08707104253965164, 0.0, -0.27189403703433945),
  (0.08913947385133272, 0.0, -0.22166070517922826),
  (0.08352516029105558, 0.0, -0.16256266770262678),
  (0.06343182754901103, 0.0, -0.11351129659704758),
  (0.05282409423263584, 0.0, -0.09442980489903194)],
 [(-0.16706665816924457, 0.0, 0.2691266640558985),
  (-0.16528715077562667, 0.0, 0.27217114445570834),
  (-0.1660017464817517, 0.0, 0.2743149315740834),
  (-0.16838373216883504, 0.0, 0.2786025058108334),
  (-0.17290950497429347, 0.0, 0.2824136829101669),
  (-0.18577222768454366, 0.0, 0.2850338671659585),
  (-0.20697190029958562, 0.0, 0.2852720657346669),
  (-0.2174526373227525, 0.0, 0.2855102643033752),
  (-0.2322209485826694, 0.0, 0.2890832428340003),
  (-0.24794205411741957, 0.0, 0.29075063281495866),
  (-0.25604080545350305, 0.0, 0.2897978385401253),
  (-0.2574699968657531, 0.0, 0.28646305857820853),
  (-0.2572317982970448, 0.0, 0.28003169722308346),
  (-0.253897018335128, 0.0, 0.2747913287115001),
  (-0.24341628131196114, 0.0, 0.26764537165024993),
  (-0.2331737428575027, 0.0, 0.2616904074325415),
  (-0.2222166086969192, 0.0, 0.2574028331957915),
  (-0.21853327370053538, 0.0, 0.25589809221268905)],
 [(0.026106828082446215, 0.0, 0.29065262670689596),
  (0.03673589001252775, 0.0, 0.293239584717799),
  (0.04493126379573342, 0.0, 0.2978492845168302),
  (0.055832167270393224, 0.0, 0.30767229835554194)],
 [(-0.22102561585337752, 0.0, 0.27645871869245847),
  (-0.22960076432687768, 0.0, 0.27764971153600015),
  (-0.2386523099377945, 0.0, 0.28074629292920855),
  (-0.24651286270516962, 0.0, 0.2850338671659586),
  (-0.2512768340793364, 0.0, 0.288130448559167),
  (-0.2530794692361926, 0.0, 0.2899593551950914)],
 [(-0.22793337434591932, 0.0, 0.2707419530434584),
  (-0.2405578984874612, 0.0, 0.2745531301427918),
  (-0.25056223837321134, 0.0, 0.2797934986543752),
  (-0.2558026068847947, 0.0, 0.28384287432241695),
  (-0.25720799049709075, 0.0, 0.28581015249586916)],
 [(-0.1783440837360873, 0.0, 0.2692593681912914),
  (-0.15606842943111493, 0.0, 0.2692593681912914),
  (-0.13558919886041448, 0.0, 0.2665082036218857),
  (-0.11546925303656842, 0.0, 0.26422938173533),
  (-0.09666429458253016, 0.0, 0.26211870407103777),
  (-0.08709773708014464, 0.0, 0.2612089940527384),
  (-0.08026030963265753, 0.0, 0.26184851917003227)],
 [(0.0009390049442551396, 0.0, 0.2764450631283793),
  (-0.011635961195648623, 0.0, 0.2807564800906321),
  (-0.029240913791513903, 0.0, 0.282552903824904),
  (-0.057624408793011034, 0.0, 0.27967862585006886),
  (-0.09277494288497992, 0.0, 0.27186689649716556),
  (-0.1182543470416265, 0.0, 0.2645471696859161)],
 [(-0.19899027040257272, 0.0, 0.099189153367939),
  (-0.20269224885443116, 0.0, 0.11325667148500115),
  (-0.20824521653221884, 0.0, 0.13324735512503683),
  (-0.21824055835223666, 0.0, 0.1647141719658337),
  (-0.22897629586262624, 0.0, 0.19062802112884294),
  (-0.2360100549211573, 0.0, 0.20654652847183427),
  (-0.23712064845671482, 0.0, 0.2180226616725955),
  (-0.23378886785004221, 0.0, 0.23579215824151617),
  (-0.22783628700463182, 0.0, 0.2474680980260887),
  (-0.2160151690922021, 0.0, 0.25837422679785277),
  (-0.2072840033134381, 0.0, 0.2652249880282507),
  (-0.1991144375858322, 0.0, 0.2650672033336348)],
 [(0.09918996745513856, 0.0, 0.027968835636233962),
  (0.13035837049671986, 0.0, 0.029057808264729344),
  (0.15748077602206112, 0.0, 0.03309463141268711),
  (0.19784900750163892, 0.0, 0.0423036342189658),
  (0.24730009106412176, 0.0, 0.05706326885368639),
  (0.2919574471384046, 0.0, 0.07535512374287008),
  (0.2919574471384046, 0.0, 0.07535512374287008),
  (0.2919574471384046, 0.0, 0.07535512374287008),
  (0.2775762646738049, 0.0, 0.09188086850482227),
  (0.2156362594973278, 0.0, 0.15609158670202575),
  (0.2156362594973278, 0.0, 0.15609158670202575),
  (0.2156362594973278, 0.0, 0.15609158670202575),
  (0.2156362594973278, 0.0, 0.15609158670202575),
  (0.11233608851148127, 0.0, 0.12466637758787844),
  (0.11233608851148127, 0.0, 0.12466637758787844),
  (0.11233608851148127, 0.0, 0.12466637758787844),
  (0.11233608851148127, 0.0, 0.12466637758787844),
  (0.07806925387280217, 0.0, 0.18234074095877506),
  (0.07806925387280217, 0.0, 0.18234074095877506),
  (0.07806925387280217, 0.0, 0.18234074095877506),
  (0.07806925387280217, 0.0, 0.18234074095877506),
  (0.05560737835775026, 0.0, 0.17353465309867425),
  (0.05560737835775026, 0.0, 0.17353465309867425),
  (0.05560737835775026, 0.0, 0.17353465309867425),
  (0.05356183621247537, 0.0, 0.21980953584187682),
  (0.05356183621247537, 0.0, 0.21980953584187682),
  (0.05356183621247537, 0.0, 0.21980953584187682),
  (0.019083390170188355, 0.0, 0.21016425263704305),
  (0.01920148271736366, 0.0, 0.21013107466953926),
  (0.01920148271736366, 0.0, 0.21013107466953926),
  (0.01920148271736366, 0.0, 0.21013107466953926)],
 [(0.028580138178180475, 0.0, 0.28332050690051297),
  (0.03982558715407328, 0.0, 0.2858037329820954),
  (0.050135649389169507, 0.0, 0.2931292854543266),
  (0.06032081873301068, 0.0, 0.30310684623154277)],
 [(0.0677991441486849, 0.0, 0.06865748355224768),
  (0.06664018935156937, 0.0, 0.07835519323217789),
  (0.06566498753168337, 0.0, 0.08891987961427611),
  (0.06306444934532077, 0.0, 0.10484817600574724),
  (0.05932617570242443, 0.0, 0.12857808695630635),
  (0.05770083933594783, 0.0, 0.13963037424834754),
  (0.05770083933594783, 0.0, 0.13963037424834754),
  (0.05770083933594783, 0.0, 0.13963037424834754),
  (0.05282483023651785, 0.0, 0.1384926387918139),
  (0.03787173566493268, 0.0, 0.13475436514891762),
  (0.01983050199704188, 0.0, 0.1315036924159643),
  (0.01983050199704188, 0.0, 0.1315036924159643),
  (0.01983050199704188, 0.0, 0.1315036924159643),
  (0.01983050199704188, 0.0, 0.1315036924159643),
  (0.020805703816927895, 0.0, 0.14125571061482417),
  (0.02828225110272045, 0.0, 0.18871553251594225),
  (0.02828225110272045, 0.0, 0.18871553251594225),
  (0.02828225110272045, 0.0, 0.18871553251594225),
  (0.02828225110272045, 0.0, 0.18871553251594225),
  (0.014051031464024408, 0.0, 0.18609097225724194),
  (0.014051031464024408, 0.0, 0.18609097225724194),
  (0.014051031464024408, 0.0, 0.18609097225724194),
  (0.014051031464024408, 0.0, 0.18609097225724194)],
 [(0.009528755339294342, 0.0, 0.11229242049984083),
  (0.009073532785421001, 0.0, 0.12547759255248564),
  (0.008757941632300828, 0.0, 0.14220392366785467),
  (0.011598262010382374, 0.0, 0.16966035398930945),
  (0.016332129307184917, 0.0, 0.2027974250669273),
  (0.023123106562470297, 0.0, 0.22253791346624777),
  (0.026812314788114328, 0.0, 0.2398988933516314),
  (0.02529322904814324, 0.0, 0.24836237104575587),
  (0.02182103307106653, 0.0, 0.25964700797125523),
  (0.01596170235974957, 0.0, 0.26507231418543764),
  (0.014442616619778512, 0.0, 0.26767646116824517),
  (0.014442616619778512, 0.0, 0.26767646116824517),
  (0.014442616619778512, 0.0, 0.26767646116824517),
  (0.02637829029097974, 0.0, 0.2733187796309948),
  (0.052202747870487815, 0.0, 0.287424575787869),
  (0.06153427455888155, 0.0, 0.29653909022769526),
  (0.06088323781317964, 0.0, 0.30239842093901226),
  (0.05893012757607399, 0.0, 0.3060876291646563),
  (0.05524091935042996, 0.0, 0.30825775165032926),
  (0.048730551893411106, 0.0, 0.3091258006445984),
  (0.039616037453584746, 0.0, 0.3076067149046273),
  (0.027897376030950827, 0.0, 0.3039175066789834),
  (0.013791579874076643, 0.0, 0.30044531070190655),
  (-0.0027013510170377925, 0.0, 0.2974071392219645),
  (-0.02423617381842573, 0.0, 0.2928124428685197),
  (-0.032445200130451296, 0.0, 0.28924110055054225),
  (-0.0348010564315414, 0.0, 0.28742525661221213),
  (-0.03416788959367409, 0.0, 0.2828053738949652)],
 [(-0.14249776955279114, 0.0, -0.1417918200556609),
  (-0.1876824690689944, 0.0, -0.16387504203073278),
  (-0.22906407954743646, 0.0, -0.19032579472606118),
  (-0.28129822715797603, 0.0, -0.24544124709836035),
  (-0.2919574471384046, 0.0, -0.26258868793644113),
  (-0.2919574471384046, 0.0, -0.2700037974880436),
  (-0.28454233758680214, 0.0, -0.2700037974880436),
  (-0.26276045327896974, 0.0, -0.2649059096713169),
  (-0.219196684663305, 0.0, -0.2552291958655296),
  (-0.14639090098898777, 0.0, -0.2228675376942308),
  (-0.1035100703582385, 0.0, -0.17287438386256543)],
 [(-0.11113979658506754, 0.0, -0.1701701485856167),
  (-0.0920479280613376, 0.0, -0.17780619957341215),
  (-0.060398425798067576, 0.0, -0.1774939840551473),
  (-0.016206616677663863, 0.0, -0.16977778852142542),
  (0.015544636019372587, 0.0, -0.14843559370632156),
  (0.035729958081267194, 0.0, -0.12736380108227793)],
 [(0.10927162780740757, 0.0, -0.010731203143760259),
  (0.11318584926224179, 0.0, -0.010926175833122396),
  (0.11815389832885312, 0.0, -0.0080274054978936),
  (0.12072745089780865, 0.0, -0.00352151288267995),
  (0.12194247359061516, 0.0, 9.031724236408168e-05),
  (0.11830935576704016, 0.0, 0.0008120586900216078),
  (0.11578169925686063, 0.0, 0.0015867643462072027),
  (0.11497687853405614, 0.0, 0.0015867643462072027),
  (0.11619033978348439, 0.0, 0.003640355790792029),
  (0.11758241991364951, 0.0, 0.00595927835361571),
  (0.11932291043720056, 0.0, 0.00938210078645657),
  (0.11893192464675287, 0.0, 0.010312576181469952),
  (0.115120187942441, 0.0, 0.012401477098406844),
  (0.11281202420386063, 0.0, 0.01333011941926368),
  (0.11288619483041368, 0.0, 0.013863503418765459),
  (0.11375071311266716, 0.0, 0.015356293512979818),
  (0.11497687853405614, 0.0, 0.017039322224054188),
  (0.11626459169054337, 0.0, 0.020580533404394124),
  (0.11513784267861699, 0.0, 0.020580533404394124),
  (0.11250165199163198, 0.0, 0.02094033036788023),
  (0.10821638446249807, 0.0, 0.02138535412719865),
  (0.10931213206592316, 0.0, 0.02208138701056822),
  (0.11077692718609328, 0.0, 0.02633157658250126),
  (0.1093194160402435, 0.0, 0.02598137002740931),
  (0.10227150098581828, 0.0, 0.027037393684098007),
  (0.09955312530456142, 0.0, 0.027655270629378),
  (0.09830321063456329, 0.0, 0.028505854695356703),
  (0.09641653798003436, 0.0, 0.031000963775540256),
  (0.08909783422280443, 0.0, 0.042083572322202736),
  (0.07780611985450678, 0.0, 0.05923024969628435),
  (0.0628664621484368, 0.0, 0.07333254609419673),
  (0.04139795178669001, 0.0, 0.09421937315440858),
  (0.014028844255788764, 0.0, 0.11150670510506955),
  (0.0073374579634642445, 0.0, 0.11297044585651551),
  (0.002737129887491141, 0.0, 0.11464329242959666)],
 [(0.05055207982869628, 0.0, -0.10325694483076527),
  (0.05363665485133942, 0.0, -0.09168978849585342),
  (0.05517894236266099, 0.0, -0.08397835093924552),
  (0.05440779860700021, 0.0, -0.07356791023782489),
  (0.0509376517065267, 0.0, -0.059687322635930684),
  (0.04823864856171389, 0.0, -0.04580673503403648),
  (0.04168392663859724, 0.0, -0.02074456297506083),
  (0.039370495371614855, 0.0, 0.0016186059391020292),
  (0.033586917204158934, 0.0, 0.014728049785335425),
  (0.022019760869247118, 0.0, 0.03246435616553357),
  (-0.0003434080449157412, 0.0, 0.04673051564525817),
  (-0.014995139402470728, 0.0, 0.05405638132403566),
  (-0.030032442637856094, 0.0, 0.0559842407131876)],
 [(0.040512732060111994, 0.0, -0.00961136628022066),
  (0.0525727846669809, 0.0, -0.014899169439004599),
  (0.06779101869839754, 0.0, -0.019012205663711815),
  (0.0889731552556397, 0.0, -0.023330893699654385),
  (0.10768747007805748, 0.0, -0.02477045637830191),
  (0.11087857474374788, 0.0, -0.02465479130369574),
  (0.11097323026910016, 0.0, -0.02178500352384688),
  (0.1107916620911113, 0.0, -0.017879869201833327),
  (0.10995928034423849, 0.0, -0.01170806477331419),
  (0.1069425222112097, 0.0, -0.00448858644409486)],
 [(-0.17179242364176184, 0.0, -0.08497069467494699),
  (-0.1602832247136593, 0.0, -0.07889969704109533),
  (-0.15218670967092027, 0.0, -0.06594527297271299),
  (-0.1512654299214483, 0.0, -0.054536205694052244),
  (-0.15327733732141346, 0.0, -0.038347955254204986),
  (-0.16119462107728277, 0.0, -0.025342851167333705),
  (-0.1717790397517378, 0.0, -0.01962882923325589),
  (-0.1799056192883628, 0.0, -0.018280140920864548)],
 [(-0.10528664926735119, 0.0, -0.059841449615678825),
  (-0.09962772241761621, 0.0, -0.055950937406486004),
  (-0.08937091750247145, 0.0, -0.05382883983783537),
  (-0.0780530638030014, 0.0, -0.054182522765943784),
  (-0.06921099060029043, 0.0, -0.05665830326270287),
  (-0.06461311253488071, 0.0, -0.05807303497513662),
  (-0.06319838082244694, 0.0, -0.05665830326270287),
  (-0.061010705251066895, 0.0, -0.05302570026763885),
  (-0.05586676905709588, 0.0, -0.04722228507444077),
  (-0.04821681266606203, 0.0, -0.042737827879696794),
  (-0.0414901268739461, 0.0, -0.03970422448325234),
  (-0.033972066282757674, 0.0, -0.03825337068495282),
  (-0.02566263089249679, 0.0, -0.03891284968417987)],
 [(-0.10567198815709404, 0.0, 0.03774334708684689),
  (-0.11265563569696412, 0.0, 0.03075969954697681),
  (-0.119918629138429, 0.0, 0.025452127416675567),
  (-0.13276854061178994, 0.0, 0.018747825778400302),
  (-0.15288144552661576, 0.0, 0.011205486435340613),
  (-0.16922318076991166, 0.0, 0.008970719222582201),
  (-0.18863772093075049, 0.0, 0.008970719222582201),
  (-0.20539847502643865, 0.0, 0.012881561844909439),
  (-0.2227179209253164, 0.0, 0.025312454465878157),
  (-0.22746680125242802, 0.0, 0.03439119626770925),
  (-0.23221568157953967, 0.0, 0.05464377413333247),
  (-0.23039993321917346, 0.0, 0.06777303150828819),
  (-0.2209021725649502, 0.0, 0.08551149625955816),
  (-0.2019066512565036, 0.0, 0.09878042658531129),
  (-0.18779968322596607, 0.0, 0.10199290445365153),
  (-0.16028411191887798, 0.0, 0.10143421265046192),
  (-0.141148917659634, 0.0, 0.09570762166776847),
  (-0.12746096848148863, 0.0, 0.0890033200294932),
  (-0.11894091848284717, 0.0, 0.08397509380078674),
  (-0.11572844061450693, 0.0, 0.08201967248962314),
  (-0.11391269225414073, 0.0, 0.08271803724361014),
  (-0.10831191409901962, 0.0, 0.08402724140487416),
  (-0.10569423321105151, 0.0, 0.08372565044932191),
  (-0.10483395045230963, 0.0, 0.08132130773563613),
  (-0.10565393556850279, 0.0, 0.07833602816480327),
  (-0.10597595355835937, 0.0, 0.07712437018567393),
  (-0.1060695789364535, 0.0, 0.07636034780560408),
  (-0.1060695789364535, 0.0, 0.07636034780560408),
  (-0.10460848207058483, 0.0, 0.07672028899229634),
  (-0.10190215137697749, 0.0, 0.07709041253900875),
  (-0.10030326153241491, 0.0, 0.07705596774357457),
  (-0.09885159569378418, 0.0, 0.0767884630999802),
  (-0.0984989120660205, 0.0, 0.07673647083413114),
  (-0.09845880688948093, 0.0, 0.07475188574617249),
  (-0.09911296193140985, 0.0, 0.0726110146998596),
  (-0.09988486182012872, 0.0, 0.07066502957116827),
  (-0.10042127201526772, 0.0, 0.06892395900898741),
  (-0.10079337141985456, 0.0, 0.06798010454794903),
  (-0.10042127201526772, 0.0, 0.06743724300460346),
  (-0.09941030513228666, 0.0, 0.06711577602486386),
  (-0.09763777665351506, 0.0, 0.06655674412846226),
  (-0.0954982838564702, 0.0, 0.06580946975769697),
  (-0.09371930088982003, 0.0, 0.06479988112398391),
  (-0.0941175961566798, 0.0, 0.06380965595390664),
  (-0.0947330242713372, 0.0, 0.06275996214365401),
  (-0.09546601141707725, 0.0, 0.06170889008413335),
  (-0.09619899856281733, 0.0, 0.060479412104086604),
  (-0.09703155952527233, 0.0, 0.05911163338005338),
  (-0.09715049680562304, 0.0, 0.058100666497072295),
  (-0.09613952992264198, 0.0, 0.05714916825426657),
  (-0.09448923325764493, 0.0, 0.055915152070497055),
  (-0.09298600749768579, 0.0, 0.0548347771738908),
  (-0.09234010733354446, 0.0, 0.0538601987933845),
  (-0.0928687547129973, 0.0, 0.05245114568041329),
  (-0.09399865887632909, 0.0, 0.05078602375550328),
  (-0.09530696896018696, 0.0, 0.049656119592171484),
  (-0.09822772695493949, 0.0, 0.0477378299772749),
  (-0.0997603223471788, 0.0, 0.046235820843605835),
  (-0.09869668145018237, 0.0, 0.04495809701831822),
  (-0.09772829910189498, 0.0, 0.043296634713294216),
  (-0.09591928800940136, 0.0, 0.04043332366114664),
  (-0.09570120863208842, 0.0, 0.03970431295751907),
  (-0.09631793584316804, 0.0, 0.038951764360607086),
  (-0.09744784000649984, 0.0, 0.038119203398152085),
  (-0.10090001530458735, 0.0, 0.037200724824330456),
  (-0.10416267788340428, 0.0, 0.03718306054407932),
  (-0.10567198815709404, 0.0, 0.03774334708684689)],
 [(-0.13298013401857137, 0.0, -0.14991114204824296),
  (-0.14069157157517925, 0.0, -0.14566985139210856),
  (-0.1437761465978224, 0.0, -0.13911512946899188),
  (-0.15071644039876952, 0.0, -0.12793354501191045),
  (-0.1576567341997166, 0.0, -0.11636638867699861),
  (-0.1626691686115117, 0.0, -0.10171465731944362),
  (-0.16382588424500288, 0.0, -0.0916897884958534),
  (-0.16729603114547642, 0.0, -0.08821964159537983),
  (-0.17423632494642355, 0.0, -0.08359277906141512),
  (-0.18156219062520107, 0.0, -0.07279676648216409),
  (-0.18541790940350494, 0.0, -0.061615182025082614),
  (-0.18657462503699618, 0.0, -0.047349022545358034),
  (-0.18464676564784416, 0.0, -0.03076943179865107),
  (-0.17616418433557554, 0.0, -0.00686397537316665),
  (-0.16729603114547642, 0.0, 0.009330043495709909)],
 [(-0.11335349932216476, 0.0, -0.11180871199749574),
  (-0.11959909764825946, 0.0, -0.11448694837022456),
  (-0.1285607787690007, 0.0, -0.1121245313922037),
  (-0.13412382759029995, 0.0, -0.1070539747064797),
  (-0.13737890595511587, 0.0, -0.09988967952566563),
  (-0.13700791962423897, 0.0, -0.09147813751100402),
  (-0.1323282510740257, 0.0, -0.0842654614530948),
  (-0.12545002301294125, 0.0, -0.08027492760280594),
  (-0.11780434280266379, 0.0, -0.07970823820105534),
  (-0.11080207909859666, 0.0, -0.08245465764761552),
  (-0.10584033076665027, 0.0, -0.08795461630885117),
  (-0.1030939113200901, 0.0, -0.09548085080597692),
  (-0.10451236949034652, 0.0, -0.10365050180931301),
  (-0.10869614459207279, 0.0, -0.10935477559089885),
  (-0.1134863572544067, 0.0, -0.1118480252788726)],
 [(-0.11202218027467242, 0.0, -0.10709056326375428),
  (-0.11374371348956538, 0.0, -0.10782879083335692),
  (-0.11621390624054272, 0.0, -0.10717761554433813),
  (-0.11774730189327375, 0.0, -0.105779970147259),
  (-0.11864452986560382, 0.0, -0.10380520784729835),
  (-0.11854227140171775, 0.0, -0.10148665513054651),
  (-0.11725237019077651, 0.0, -0.09949855715279551),
  (-0.11535645927103444, 0.0, -0.09839860864350311),
  (-0.11324900827191253, 0.0, -0.09824240669507402),
  (-0.11131890823720078, 0.0, -0.09899942820885389),
  (-0.10995125471364693, 0.0, -0.1005154337252983),
  (-0.10919423319986706, 0.0, -0.1025899607751313),
  (-0.1095852162132687, 0.0, -0.10484183878937448),
  (-0.11073842963257732, 0.0, -0.10641416161084281),
  (-0.11205880116049867, 0.0, -0.10710139955455351)],
 [(0.0098947348821216, 0.0, -0.07545103044684087),
  (0.0036491365560269023, 0.0, -0.0781292668195697),
  (-0.005312544564714361, 0.0, -0.07576684984154886),
  (-0.010875593386013585, 0.0, -0.07069629315582485),
  (-0.014130671750829493, 0.0, -0.06353199797501076),
  (-0.013759685419952608, 0.0, -0.05512045596034917),
  (-0.00908001686973936, 0.0, -0.04790777990243994),
  (-0.0022017888086548892, 0.0, -0.043917246052151075),
  (0.005443891401622575, 0.0, -0.043350556650400475),
  (0.012446155105689707, 0.0, -0.04609697609696065),
  (0.017407903437636082, 0.0, -0.05159693475819631),
  (0.020154322884196246, 0.0, -0.059123169255322065),
  (0.018735864713939843, 0.0, -0.06729282025865815),
  (0.014552089612213576, 0.0, -0.07299709404024399),
  (0.009761876949879678, 0.0, -0.07549034372821772)],
 [(-0.06009400225542736, 0.0, -0.0722858624290706),
  (-0.061441021886439066, 0.0, -0.07294979744206781),
  (-0.06353548818002308, 0.0, -0.07288644430077773),
  (-0.06492953723068402, 0.0, -0.07225701472335197),
  (-0.06585457579998127, 0.0, -0.07120147112169077),
  (-0.06598954735517379, 0.0, -0.06981083812486184),
  (-0.06511587923302167, 0.0, -0.06846098646209658),
  (-0.06365953651438633, 0.0, -0.0675593523339448),
  (-0.06193990591450635, 0.0, -0.06719061350580212),
  (-0.0602799223678165, 0.0, -0.06738756103362689),
  (-0.05901108972301049, 0.0, -0.06810900025042399),
  (-0.05819200963687807, 0.0, -0.06924216397370368),
  (-0.05830095455399098, 0.0, -0.0706309976418792),
  (-0.05910142640328005, 0.0, -0.0717159766371897),
  (-0.060123116423297054, 0.0, -0.07229709449539715)],
 [(0.0034191589570200243, 0.0, -0.0722600261400743),
  (0.0016976257421270485, 0.0, -0.07299825370967694),
  (-0.0007725670088502695, 0.0, -0.07234707842065816),
  (-0.0023059626615812845, 0.0, -0.07094943302357902),
  (-0.0032031906339113764, 0.0, -0.06897467072361839),
  (-0.003100932170025286, 0.0, -0.06665611800686655),
  (-0.0018110309590840673, 0.0, -0.06466802002911554),
  (8.487996065800751e-05, 0.0, -0.06356807151982313),
  (0.0021923309597799284, 0.0, -0.06341186957139404),
  (0.004122430994491666, 0.0, -0.06416889108517392),
  (0.005490084518045529, 0.0, -0.06568489660161832),
  (0.006247106031825406, 0.0, -0.06775942365145134),
  (0.005856123018423767, 0.0, -0.0700113016656945),
  (0.004702909599115124, 0.0, -0.07158362448716285),
  (0.0033825380711937914, 0.0, -0.07227086243087354)]]

lesson5_节点类型和属性的获取


image.png

image.png
import maya.cmds as cmds
import json

sel = cmds.ls(sl=True)
data = {}
for obj in sel:
    obj_data = {}
    all_settable_attr = cmds.listAttr(obj, settable=True)
    obj_type =  cmds.nodeType(obj)
    obj_shape = cmds.listRelatives(obj, s=True)
    if obj_shape:
        obj_shape_type = cmds.nodeType(obj_shape[0])
    else:
        obj_shape_type = obj_type
    obj_data['node_type'] = obj_type
    obj_data['node_shape_type'] = obj_shape_type
    for attr in all_settable_attr:
        try:
            attr_value = cmds.getAttr('{}.{}'.format(obj, attr))
            if attr_value:
                attr_type = cmds.getAttr('{}.{}'.format(obj, attr), typ=True)
                obj_data[attr] = [attr_value, attr_type]               
        except:
            data[obj] = obj_data
    
file_path = r'C:\Users\KangTa\Desktop\test.json'
json_str = json.dumps(data, indent=4)
with open(file_path, 'w') as f:
    f.write(json_str)

lesson6_节点及其属性的连接和断开


image.png

image.png
sel_obj = cmds.ls(sl=True, tr=True, long=True)[0]
blend_color_node = cmds.createNode('blendColors')
color_list = [(1, 0, 0), (0, 1, 0)]
for index, color in enumerate(color_list):
    lambert_shader = cmds.shadingNode('lambert', name="test_lambert{}".format(index), asShader=True)
    shader_sg = cmds.sets(name='{}_SG'.format(lambert_shader), empty=True, renderable=True, noSurfaceShader=True)
    cmds.connectAttr('{}.outColor'.format(lambert_shader), '{}.surfaceShader'.format(shader_sg))
    cmds.setAttr('{}.color'.format(lambert_shader), color[0], color[1], color[2], type='double3')
    
    cmds.connectAttr('{}.outColor'.format(lambert_shader), '{}.color{}'.format(blend_color_node, index+1))

obj_shader = cmds.shadingNode('lambert', name="{}_lambert".format(sel_obj), asShader=True)  
obj_shader_sg = cmds.sets(name='{}_SG'.format(obj_shader), empty=True, renderable=True, noSurfaceShader=True)
cmds.connectAttr('{}.outColor'.format(obj_shader), '{}.surfaceShader'.format(obj_shader_sg))
cmds.sets(sel_obj, e=True, forceElement=obj_shader_sg)       
cmds.connectAttr('{}.output'.format(blend_color_node), '{}.color'.format(obj_shader))  
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,194评论 6 490
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,058评论 2 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 156,780评论 0 346
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,388评论 1 283
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,430评论 5 384
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,764评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,907评论 3 406
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,679评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,122评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,459评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,605评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,270评论 4 329
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,867评论 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,734评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,961评论 1 265
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,297评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,472评论 2 348