{"id":7488,"date":"2013-05-01T20:09:46","date_gmt":"2013-05-01T11:09:46","guid":{"rendered":"http:\/\/leavebehind.iobb.net\/wordpress\/?p=7488"},"modified":"2013-05-01T20:09:46","modified_gmt":"2013-05-01T11:09:46","slug":"import-molecular-structure-to-maya","status":"publish","type":"post","link":"http:\/\/leavebehind.mydns.jp\/wordpress\/2013\/05\/01\/import-molecular-structure-to-maya\/","title":{"rendered":"Import molecular structure to Maya"},"content":{"rendered":"<p>\u3072\u3063\u3055\u3057\u3076\u308a\u306eCG\u306e\u8a18\u4e8b\u3067\u3059\u3088\u3002\u8ab0\u304c\u8208\u5473\u3042\u3093\u306d\u3093\u3063\u3066\u306a\u5185\u5bb9\u3067\u3059\u3088\uff01<\/p>\n<p>\u304a\u4ed5\u4e8b\u3067\u3001\u3042\u308b\u9ad8\u5206\u5b50\u3092\u30e2\u30c7\u30ea\u30f3\u30b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u3066\u3001<a href=\"http:\/\/avogadro.openmolecules.net\/\">Avogadro<\/a>\u3068\u8a00\u3046\u30d5\u30ea\u30fc\u30bd\u30d5\u30c8\u3092\u898b\u3064\u3051\u307e\u3057\u305f\u3002\u65e2\u77e5\u306e\u5206\u5b50\u69cb\u9020\u306f\u3082\u3061\u308d\u3093\u547c\u3073\u51fa\u305b\u307e\u3059\u3057\u3001\u81ea\u5206\u3067\u5206\u5b50\u3092\u30e2\u30c7\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u3082\u51fa\u6765\u3001\u975e\u5e38\u306b\u8208\u5473\u6df1\u3044\u306e\u3067\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u3053\u3068\u306b3D\u306e\u66f8\u304d\u51fa\u3057\u304cPOV-Ray\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3064\u30fc\u3053\u3068\u3067python\u306e\u304a\u52c9\u5f37\u3092\u517c\u306d\u3066\u8aad\u307f\u8fbc\u307f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2013\/05\/Tryptophan_trim.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2013\/05\/Tryptophan_trim.jpg\" alt=\"Tryptophan_trim\" width=\"1280\" height=\"720\" class=\"aligncenter size-full wp-image-7498\" \/><\/a><\/p>\n<p>Avogadro\u306e\u8aac\u660e\u306f\u7701\u304d\u307e\u3059\u3001\u5206\u5b50\u306f\u300cFile\/Import\u300d\u304b\u3089\u547c\u3073\u51fa\u305b\u307e\u3059\u3002\u300cFile\/Export\/POV-ray&#8230;\u300d\u3067\u66f8\u304d\u51fa\u3057\u305f\u3089\u6b21\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3066pov\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3060\u3051\u3067\u3059\u3002\u30e1\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u306b\u306f\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u305b\u3093\u3001\u30d5\u30a1\u30a4\u30eb\u5185\u306ecylinder\u3068sphere\u306e\u60c5\u5831\u3092\u8aad\u307f\u53d6\u308b\u3060\u3051\u3067\u3059\u3002Maya2013 x64 Extension2\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<pre class=\"lang:python nums='false' title='Importing Avogadro POV file to Maya'\">\nimport pymel.core as pm\nimport pymel.core.datatypes as dt\nimport re\nimport math\n\ndef htAimY(vec):\n    outAngle = []\n    xyLength = dt.Vector(vec.x,vec.y,0).length()\n    vecLength = vec.length()\n    if xyLength == 0:\n        zAngle = math.radians(90) if vec.x > 0 else math.radians(-90)\n    else:\n        zAngle = math.acos(vec.y\/xyLength)\n    xAngle = math.acos(xyLength\/vecLength)\n    xAngle = xAngle if vec.z > 0 else xAngle * -1\n    outAngle.append(math.degrees(xAngle))\n    zAngle = zAngle * -1 if vec.x > 0 else zAngle;\n    outAngle.append(math.degrees(zAngle))\n    return outAngle\n\nbasicFilter = \"*.pov\"\nfileName = pm.system.fileDialog2(fileFilter = basicFilter, fileMode = 1, dialogStyle = 2,caption = \"Open moleculer geometry\")\nif fileName:\n    print(\"load file name: \" + fileName[0])\n    \n    filePointer = open(fileName[0])\n    line = filePointer.readline()\n    \n    while line:\n        if re.search(\"cylinder\",line):\n            line = filePointer.readline()\n            matchList = re.findall(\"-?[0-9]+\\.[0-9]+[eE][-+]?[0-9]+|-?[0-9]+\\.[0-9]+|-?[0-9]+\",line)\n            startcap = dt.Vector(float(matchList[0]),float(matchList[1]),float(matchList[2]))\n            endcap = dt.Vector(float(matchList[3]),float(matchList[4]),float(matchList[5]))\n            nodeList = pm.modeling.polyCylinder(radius=float(matchList[6]), height=((startcap - endcap).length()))\n            nodeList[0].translate.set((endcap - startcap)\/2 + startcap)\n            angle = htAimY(startcap - endcap)\n            nodeList[0].rotate.set([angle[0],0,angle[1]])\n        if re.search(\"sphere\",line):\n            line = filePointer.readline()\n            matchList = re.findall(\"-?[0-9]+\\.[0-9]+[eE][-+]?[0-9]+|-?[0-9]+\\.[0-9]+|-?[0-9]+\",line)\n            nodeList = pm.modeling.polySphere(radius=float(matchList[3]))\n            nodeList[0].translate.set([float(matchList[0]),float(matchList[1]),float(matchList[2])])\n        line = filePointer.readline()\n    filePointer.close()\n<\/pre>\n<p>\u8272\u3082\u6301\u3063\u3066\u6765\u305f\u3044\u5834\u5408\u306f\u300cpigment\u300d\u304c\u305d\u308c\u3067\u3059\u306e\u3067\u30b4\u30cb\u30e7\u30b4\u30cb\u30e7\u3084\u308c\u3070\u3044\u3044\u3068\u601d\u3044\u307e\u3059\u3002<a href=\"http:\/\/www.povray.org\/documentation\/\">POV-Ray\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8<\/a>\u3082\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<a href=\"http:\/\/www.povray.org\/documentation\/view\/3.6.1\/278\/\">Cylinder\u306e\u8a18\u8ff0<\/a>\u304c\u300c\u5e95\u9762\u306e\u4e2d\u5fc3\u70b9\u3001\u4e0a\u9762\u306e\u4e2d\u5fc3\u70b9\u3001\u534a\u5f84\u300d\u3068\u304b\u2026\u3001\u4e00\u756a\u30e1\u30f3\u30c9\u30a4\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u4e2d\u306e\u6b63\u898f\u8868\u73fe\u304c\u9069\u5f53\u306a\u4e0a\u3001\u4e71\u66b4\u306b\u30d1\u30fc\u30b9\u3057\u3066\u307e\u3059\u3002Avogadro\u81ea\u4f53\u3092Python\u3067\u547c\u3073\u51fa\u305b\u305d\u3046\u306a\u3053\u3068\u304c\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3001pov\u30d5\u30a1\u30a4\u30eb\u7d4c\u7531\u3059\u308b\u306e\u306f\u9060\u56de\u308a\u306a\u3093\u3067\u3059\u3051\u3069\u306d\u3002\u307e\u3041\u52d5\u304d\u307e\u3059\u3002\u3042\u3068Python\u306e\u5909\u6570\u306e\u30b9\u30b3\u30fc\u30d7\u3063\u3066\u3069\u30fc\u306a\u3063\u3066\u308b\u306e\uff1f\u5909\u6570\u540d\u3068\u304b\u304b\u3076\u3063\u3066\u305f\u3089\u30b4\u30e1\u30f3\u30ca\u30b5\u30a4\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u4e0b\u306e\u5206\u5b50\u306f\u30ab\u30c6\u30ad\u30f3\u3001\u6700\u521d\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u305f\u3082\u306e\u306f\u30c8\u30ea\u30d7\u30c8\u30d5\u30a1\u30f3\u3002<\/p>\n<p><a href=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2013\/05\/importPOVToMaya.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/leavebehind.iobb.net\/wordpress\/wp-content\/uploads\/2013\/05\/importPOVToMaya.jpg\" alt=\"importPOVToMaya\" width=\"1280\" height=\"800\" class=\"aligncenter size-full wp-image-7494\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3072\u3063\u3055\u3057\u3076\u308a\u306eCG\u306e\u8a18\u4e8b\u3067\u3059\u3088\u3002\u8ab0\u304c\u8208\u5473\u3042\u3093\u306d\u3093\u3063\u3066\u306a\u5185\u5bb9\u3067\u3059\u3088\uff01 \u304a\u4ed5\u4e8b\u3067\u3001\u3042\u308b\u9ad8\u5206\u5b50\u3092\u30e2\u30c7\u30ea\u30f3\u30b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u3066\u3001Avogadro\u3068\u8a00\u3046\u30d5\u30ea\u30fc\u30bd\u30d5\u30c8\u3092\u898b\u3064\u3051\u307e\u3057\u305f\u3002\u65e2\u77e5\u306e\u5206\u5b50\u69cb\u9020\u306f\u3082\u3061\u308d\u3093\u547c\u3073\u51fa\u305b\u307e\u3059\u3057\u3001\u81ea\u5206\u3067\u5206\u5b50\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,15],"tags":[28,169,175,229,230],"class_list":["post-7488","post","type-post","status-publish","format-standard","hentry","category-cg","category-15","tag-3d","tag-macromolecule","tag-maya","tag-pymel","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8YSE4-1WM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/7488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=7488"}],"version-history":[{"count":0,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/posts\/7488\/revisions"}],"wp:attachment":[{"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=7488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=7488"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leavebehind.mydns.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=7488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}