Python/ja: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 9: Line 9:
WikipediaのPyhtonの記事はこちら: http://en.wikipedia.org/wiki/Python_(programming_language)
WikipediaのPyhtonの記事はこちら: http://en.wikipedia.org/wiki/Python_(programming_language)


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


== Pythonのバージョン ==
== Pythonのバージョン ==
Line 17: Line 17:
Vectorworksは、Python 3を使用しています。これは言語を習得してコードを書く上で非常に重要な点です。
Vectorworksは、Python 3を使用しています。これは言語を習得してコードを書く上で非常に重要な点です。


! Vectorworksは、VW2015ではPython 3.3を使用しています。 Keep this in mind, as python adds new stuff in minor releases like enums in 3.4.
! Vectorworksは、VW2015ではPython 3.3を使用しています。 Pythonは、3.4でのenumのようにマイナーリリースで新しい機能を追加していることに注意してください。


== Pythonの始め方 ==
== Pythonの始め方 ==


まず始めに、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 29: Line 29:
== Python 3とVectorworks ==
== Python 3とVectorworks ==


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スクリプトのデバッグ ==


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|vs.py (python file)]] (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.
ユーザは外部のIDEを使用してVectorworksが実行するPythonスクリプトを編集できます。最新のIDEは、インテリセンスな情報 (入力中のコード補完機能) を提供しています。VectorworksのPythonスクリプトAPIでインテリセンスを使用するには、IDEで次のファイルを読み込みます: [[File:vs.zip|vs.py (python file)]] (ダウンロードして解凍し、IDEが分かる場所に保存してください。) こうすることで、IDEはVectorworksのPython関数をすべて把握し、パラメータや関数の動作に関する情報を提供できるようになります。なお、これらの関数は空であり、実行しない限り動作しません。


It is possible to debug Python scripts in Vectorworks using a third-party application.


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


List of some good IDE's:
詳しくはこちらを参照してください: [[Python Debugging]]
* [http://www.aptana.com/products/studio3/download.html Aptana Studio 3] (Free)
* [http://www.jetbrains.com/pycharm/ PyCharm] (Free community edition, Paid full version)


== See Also ==
IDEのリスト:
* [http://www.aptana.com/products/studio3/download.html Aptana Studio 3] (無料)
* [http://www.jetbrains.com/pycharm/ PyCharm] (コミュニティエディションは無料、フルバージョンは有料)
 
== 関連項目 ==


* [[Vectorworks Scripting#Common Tasks|Scripting Common Tasks]]
* [[Vectorworks Scripting#Common Tasks|Scripting Common Tasks]]
Line 77: Line 78:
* [https://wiki.python.org/moin/BeginnersGuide/Programmers List of Python tutorials for programmers]
* [https://wiki.python.org/moin/BeginnersGuide/Programmers List of Python tutorials for programmers]


== Notes ==
== 注記 ==


<references />
<references />

Latest revision as of 01:54, 15 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スクリプトのデバッグ

ユーザは外部のIDEを使用してVectorworksが実行するPythonスクリプトを編集できます。最新のIDEは、インテリセンスな情報 (入力中のコード補完機能) を提供しています。VectorworksのPythonスクリプトAPIでインテリセンスを使用するには、IDEで次のファイルを読み込みます: File:Vs.zip (ダウンロードして解凍し、IDEが分かる場所に保存してください。) こうすることで、IDEはVectorworksのPython関数をすべて把握し、パラメータや関数の動作に関する情報を提供できるようになります。なお、これらの関数は空であり、実行しない限り動作しません。


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

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

IDEのリスト:

  • Aptana Studio 3 (無料)
  • PyCharm (コミュニティエディションは無料、フルバージョンは有料)

関連項目

注記

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