Python/ja: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(Created page with "{{LocationMain|category=LocationPYSpecial|specific=}} <div class="rightmenu"> __TOC__ </div> == Pythonとは == Pythonとは、より迅速な作業とシステムの統合...")
 
No edit summary
Line 11: Line 11:
さらに詳しくは、こちらのウェブサイト(英語)を参照してください: http://www.python.org/
さらに詳しくは、こちらのウェブサイト(英語)を参照してください: http://www.python.org/


== Python Version ==
== Pythonのバージョン ==


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


Vectorworks uses Python 3 language. This is very important when learning about the language and when writing code.
Vectorworksは、Python 3を使用しています。これは言語を学んでコードを書く上で非常に重要です。


! Vectorworks uses Python 3.3 at the moment, which is for VW2015. Keep this in mind, as python adds new stuff in minor releases like enums in 3.4.
! Vectorworks uses Python 3.3 at the moment, which is for VW2015. Keep this in mind, as python adds new stuff in minor releases like enums in 3.4.

Revision as of 08:01, 7 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 uses Python 3.3 at the moment, which is for VW2015. Keep this in mind, as python adds new stuff in minor releases like enums in 3.4.

How to start with Python

First of all you must learn the Python 3 language. The best place to start is the Python documentation page(http://www.python.org/doc/).

The fastest way to learn the language is to read through Python Tutorial pages: http://docs.python.org/3/tutorial/

A very good guide at writing good code and perform common tasks can be found at The Hitchhiker’s Guide to Python!

Python 3 and Vectorworks

Scripting in Vectorworks with Python is very similar to the way VectorScript works in the software. All the existing APIs are available in the Python scripts inside the 'vs' namespace. Of course, all of the power of the Python engine is available, so that Python style type inference, classes, iterators, libraries, dictionaries, modules, packages sequence types like lists, tuples and ranges are available in the Vectorworks environment.

To get started, here is a simple script in Python that displays an alert dialog looks like this:

  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

When executed with a double-click on the script label in the resource browser, the alert dialog will be displayed.

Python API

Full functional reference to the Python Vectorworks API can be found on this page VS:Function_Reference.

Samples

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 and Debugging Python Scripts

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