Python/ja: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
No edit summary
No edit summary
Line 23: Line 23:
まず始めに、Python 3を学ぶ必要があります。最初に、Pythonのドキュメンテーションページを参照するとよいでしょう:http://www.python.org/doc/
まず始めに、Python 3を学ぶ必要があります。最初に、Pythonのドキュメンテーションページを参照するとよいでしょう:http://www.python.org/doc/


言語を学ぶのに最も早い方法は、Pythonのチュートリアルページを読むことです:http://docs.python.org/3/tutorial/
言語を学ぶのに最も早い方法は、Pythonのチュートリアルページを読むことです: http://docs.python.org/3/tutorial/


良いコードを書く方法、よくあるタスクを実行する方法のガイドについては、こちらを参照してください:[http://docs.python-guide.org/en/latest/ The Hitchhiker’s Guide to Python!]
良いコードを書く方法、よくあるタスクを実行する方法のガイドについては、こちらを参照してください:[http://docs.python-guide.org/en/latest/ The Hitchhiker’s Guide to Python!]
Line 31: Line 31:
VectorworksでのPythonスクリプティングは、ソフトウェアで[[VectorScript]]が動くのにとても似ています。Pythonスクリプトでは、「vs」という名前空間に存在するすべてのAPIが使用できます。もちろん、Pythonエンジンのすべての機能が使用でき、Pythonスタイルの型推論、クラス、イテレータ、ライブラリ、辞書、モジュール、list、tuple、rangeなどのパッケージシーケンス型もVectorworks環境で使用できます。
VectorworksでのPythonスクリプティングは、ソフトウェアで[[VectorScript]]が動くのにとても似ています。Pythonスクリプトでは、「vs」という名前空間に存在するすべてのAPIが使用できます。もちろん、Pythonエンジンのすべての機能が使用でき、Pythonスタイルの型推論、クラス、イテレータ、ライブラリ、辞書、モジュール、list、tuple、rangeなどのパッケージシーケンス型もVectorworks環境で使用できます。


例えば、アラートダイアログを表示する簡単なPythonスクリプトは以下のようになります:
例えば、アラートダイアログを表示する簡単なPythonスクリプトは以下のようになります:


[[Image:SimplePythonInVectorworks.jpg]]
[[Image:SimplePythonInVectorworks.jpg]]
Line 43: Line 43:
== Python API ==
== Python API ==


Python Vectorworks APIの完全な機能についてのリファレンスは、こちらのページを参照してください:[[VS:Function_Reference]]
Python Vectorworks APIの完全な機能についてのリファレンスは、こちらのページを参照してください: [[VS:Function_Reference]]


== サンプル ==
== サンプル ==


These are some introductory samples that demonstrate plug-ins for Vectorworks written in Python. They are with increasing difficulty and demonstrate different aspects in the plug-in development under Vectorworks:
以下は、Pythonで書かれたVectorworks用プラグインの初歩的なサンプルです。下に行くほど複雑になっており、Vectorworksにおけるプラグイン開発の様々な特徴を表しています:


* Sample menu command: [[Python Sample Menu Command]]
* メニューコマンドのサンプル: [[Python Sample Menu Command]]
* Sample point object: [[Python Sample Point Object]]
* 点オブジェクトのサンプル: [[Python Sample Point Object]]
* Sample more complex point object: [[Python Sample Point Object (complex)]]
* より複雑な点オブジェクトのサンプル: [[Python Sample Point Object (complex)]]
* Sample 2D path object: [[Python Sample 2D Path Object]]
* 2Dパス図形のサンプル: [[Python Sample 2D Path Object]]
* An object that display an image from the web: [[Python Sample WebLinkImage]]
* Webのイメージを表示するオブジェクトのサンプル: [[Python Sample WebLinkImage]]
* Sample of a menu and two objects: [[Python Sample Menu with Two Objects]]
* メニューと2つのオブジェクトのサンプル: [[Python Sample Menu with Two Objects]]
* Sample that imports a folder of .png images as symbols: [[Python Sample Import Images as Symbols]]
* .png画像のフォルダをシンボルとして取り込むサンプル: [[Python Sample Import Images as Symbols]]
* Sample scripts to elevation information of VW objects: [[Python sample to Import elevation]]
* VWオブジェクトの高さ情報を取り込むサンプル: [[Python sample to Import elevation]]


== IDEおよびPythonスクリプトのデバッグ ==
== IDEおよびPythonスクリプトのデバッグ ==
Line 64: Line 64:
Vectorworksでは、サードパーティプラグインを使用してPythonスクリプトをデバッグすることができます。
Vectorworksでは、サードパーティプラグインを使用してPythonスクリプトをデバッグすることができます。


See [[Python Debugging]] for more information.
詳しくはこちらを参照してください: [[Python Debugging]]


List of some good IDE's:
List of some good IDE's:

Revision as of 00:33, 12 December 2017

.Python|Python ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix ..Python Debugging|Debugging with Python

Pythonとは

Pythonとは、より迅速な作業とシステムの統合を可能にするプログラミング言語です。Pythonを習得することで、生産性が即座に向上し、メンテナンスのコストも削減できます。[1]

WikipediaのPyhtonの記事はこちら: http://en.wikipedia.org/wiki/Python_(programming_language)

さらに詳しくは、こちらのウェブサイト(英語)を参照してください: http://www.python.org/

Pythonのバージョン

Pythonには、Python 2.7と3.xの2つのバージョンがあります。

Vectorworksは、Python 3を使用しています。これは言語を習得してコードを書く上で非常に重要な点です。

! Vectorworksは、VW2015ではPython 3.3を使用しています。 Pythonは、3.4でのenumのようにマイナーリリースで新しい機能を追加していることに留意してください。

Pythonの始め方

まず始めに、Python 3を学ぶ必要があります。最初に、Pythonのドキュメンテーションページを参照するとよいでしょう:http://www.python.org/doc/

言語を学ぶのに最も早い方法は、Pythonのチュートリアルページを読むことです: http://docs.python.org/3/tutorial/

良いコードを書く方法、よくあるタスクを実行する方法のガイドについては、こちらを参照してください:The Hitchhiker’s Guide to Python!

Python 3とVectorworks

VectorworksでのPythonスクリプティングは、ソフトウェアでVectorScriptが動くのにとても似ています。Pythonスクリプトでは、「vs」という名前空間に存在するすべてのAPIが使用できます。もちろん、Pythonエンジンのすべての機能が使用でき、Pythonスタイルの型推論、クラス、イテレータ、ライブラリ、辞書、モジュール、list、tuple、rangeなどのパッケージシーケンス型もVectorworks環境で使用できます。

例えば、アラートダイアログを表示する簡単なPythonスクリプトは以下のようになります:

  1. リソースブラウザで右クリックして、新しいスクリプトを作成します
  2. スクリプト言語で「Python」を選択します
  3. スクリプトを入力します

リソースマネージャでスクリプトラベルをダブルクリックして実行すると、アラートダイアログが表示されます。

Python API

Python Vectorworks APIの完全な機能についてのリファレンスは、こちらのページを参照してください: VS:Function_Reference

サンプル

以下は、Pythonで書かれたVectorworks用プラグインの初歩的なサンプルです。下に行くほど複雑になっており、Vectorworksにおけるプラグイン開発の様々な特徴を表しています:

IDEおよびPythonスクリプトのデバッグ

Often users would use external IDE to edit the Python scripts that Vectorworks executes. Modern IDEs provide intelli-sense information (information about the semantics of the code while typing). To help intelli-sense for Vectorworks Python script APIs, you can point your IDE to the file File:Vs.zip (download, unzip, and place it appropriately so the IDE could find it). This way the IDE will know all Vectorworks Python functions and it would provide some information on the parameters and the behavior of the function. Note that those functions are empty and will not do anything if executed.

Vectorworksでは、サードパーティプラグインを使用してPythonスクリプトをデバッグすることができます。

詳しくはこちらを参照してください: Python Debugging

List of some good IDE's:

関連項目

Notes

  1. As described on the Python official website: http://www.python.org