Warning: Use of undefined constant ace - assumed 'ace' (this will throw an Error in a future version of PHP) in /home/luxology/www/web_new/tipsblog/wp-content/plugins/advanced-category-excluder/advanced-category-excluder.php on line 310

Warning: Use of undefined constant ace - assumed 'ace' (this will throw an Error in a future version of PHP) in /home/luxology/www/web_new/tipsblog/wp-content/plugins/advanced-category-excluder/advanced-category-excluder.php on line 310
Get Data From CSV File — MODO 機能紹介・チップスサイト



MODO 機能紹介・チップスサイト このサイトでは、MODOの基本機能やチップスをご紹介していきます。

Get Data From CSV File

ダウンロード

バージョン

v1.1

概要

こ のスクリプトはCSVファイルに書き込まれている頂点情報を読み込み、MODO上で点ポリゴン化します。

注意

CSVファイルにはXYZ座標値が書き込まれているものとします。CSVファイルの区切り文字は ‘,’ とします。


0,0.1,0
0,0.2,0
0,0.3,0
0,0.4,0
0,0.5,0
0,0.6,0
0,0.7,0
0,0.8,0
0,0.9,0
0,1,0

解説

このスクリプトではXYZ座標値が書き込まれたCSVファイルを読み込み、MODO上でその座標値に対して点ポリゴンを作成します。

blob_csv本スクリプトではCSVファイルを指定するために、ファイルダイアログを開きますが、このファイルダイアログを開くためのソースは、SDK Wikiの下記のページに掲載されています:

http://sdk.luxology.com/wiki/Dialog_Commands

これを元にCSVファイルを指定した後は、1行ずつ読み込んで、実際にポイントを作成しています。ポイントを作成するには、vert.new を使用すればOKなのですが、今回点ポリゴン化するところまでを考え、ポイントツールを起動し、点ポリゴン化のオプションをオンにした状態で適用するようにしています:

50:    # Activate Point Tool
 51:    lx.eval( ‘tool.set prim.makeVertex on 0′ )
 52:    lx.eval( ‘tool.attr prim.makeVertex polygon true’ )
 53:
 54:    # Read each line
 55:    for line in csv_file :
 56:
 57:        # Get point position from line
 58:        px, py, pz = line.split( ‘,’ )
 59:
 60:        # Set Point Position and apply
 61:        lx.eval( ‘tool.attr prim.makeVertex cenX %s’ % px )
 62:        lx.eval( ‘tool.attr prim.makeVertex cenY %s’ % py )
 63:        lx.eval( ‘tool.attr prim.makeVertex cenZ %s’ % pz )
 64:        lx.eval( ‘tool.apply’ )
 65:
 66:    # Drop Point Tool
 67:    lx.eval( ‘tool.set prim.makeVertex off 0′ )

※ver1.1において、進捗バーを出すように修正しました。

2015年2月24日