Python/ja

From Vectorworks Developer
Revision as of 01:02, 11 December 2017 by Yoshimura (talk | contribs)
Jump to navigation Jump to search

.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を使用しています。 Keep this in mind, as python adds new stuff in minor releases like enums in 3.4.

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. Right-click on the resource browser and create a new script
  2. Choose language for the script to be 'Python'
  3. Type the script

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

Python API

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:

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.

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

See Python Debugging for more information.

List of some good IDE's:

See Also

Notes

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