Macros/ja: Difference between revisions

From FreeCAD Documentation
(Created page with "===カスタマイズ=== もちろん、マクロを使用するたびに、エディタでマクロを開くのは実用的ではありません。 FreeCADは、マクロに...")
(Created page with "===記録せずにマクロを作成する=== また、直接GUI操作を記録せずに、マクロにpythonコードをコピー/ペーストすることができます。...")
Line 28: Line 28:
[[Customize_Toolbars|Customize Toolbars]] This way you can make your macro become a real tool, just like any standard FreeCAD tool. This, added to the power of python scripting within FreeCAD, makes it possible to easily add your own tools to the interface. Read on to the [[Scripting]] page if you want to know more about python scripting...
[[Customize_Toolbars|Customize Toolbars]] This way you can make your macro become a real tool, just like any standard FreeCAD tool. This, added to the power of python scripting within FreeCAD, makes it possible to easily add your own tools to the interface. Read on to the [[Scripting]] page if you want to know more about python scripting...


===記録せずにマクロを作成する===
===Creating macros without recording===

[[How to install macros]] You can also directly copy/paste python code into a macro, without recording GUI action. Simply create a new macro, edit it, and paste your code. You can then save your macro the same way as you save a FreeCAD document. Next time you start FreeCAD, the macro will appear under the "Installed Macros" item of the Macro menu.
また、直接GUI操作を記録せずに、マクロにpythonコードをコピー/ペーストすることができます。新しいマクロを作成・編集して、コードを貼り付けます。あなたのマクロはFreeCADの文書を保存するのと同じ方法で保存することができます。FreeCADを次回起動する時には、マクロは「Macro」メニューの"Installed Macros"項目の下に表示されます。


===Macros repository===
===Macros repository===

Revision as of 18:53, 8 December 2018

Macros are a convenient way to create complex actions in FreeCAD. You simply record actions as you do them, then save that under a name, and replay them whenever you want. Since macros are in reality a list of python commands, you can also edit them, and create very complex scripts.

How it works

If you enable console output (Menu Edit -> Preferences -> General -> Macros -> Show scripts commands in python console), you will see that in FreeCAD, every action you do, such as pressing a button, outputs a python command. Those commands are what can be recorded in a macro. The main tool for making macros is the macros toolbar: . On it you have 4 buttons: Record, stop recording, edit and play the current macro.

It is very simple to use: Press the record button, you will be asked to give a name to your macro, then perform some actions. When you are done, click the stop recording button, and your actions will be saved. You can now access the macro dialog with the edit button:

There you can manage your macros, delete, edit, duplicate, install or create new ones from scratch. If you edit a macro, it will be opened in an editor window where you can make changes to its code. New macros can be installed using the Addons... button, which links to the AddonManager.

「記録」ボタンを押して名前をつけてみましょう。"cylinder 10×10"にします。その後、パートワークベンチで、半径= 10、高さ= 10でシリンダを作成します。そして、「記録停止」ボタンを押してください。マクロ編集のダイアログでは、記録されているPythonのコードを見ることができ、必要に応じて変更を加えることができます。マクロを実行する簡単な方法は、マクロをエディタで開きツールバー上の「実行」ボタンを押します。 マクロは常にディスクに保存され、あなたが行ったすべての変更、または新しく作成したマクロはFreeCADを次回起動時も利用できるようになっています。

カスタマイズ

もちろん、マクロを使用するたびに、エディタでマクロを開くのは実用的ではありません。 FreeCADは、マクロにキーボードショートカットを割り当てる、メニューのエントリに追加するなど、マクロを使用するためのはるかに優れた方法を提供します。マクロが作成されると、Tools -> Customize メニューから設定を行うことができます

この方法であなたのマクロをFreeCADの標準ツールのように使うことができます。これは、FreeCADのpythonスクリプトの力のおかげで、インターフェイスに独自のツールを簡単に追加することができます。Pythonスクリプティングについて詳細をお知りになりたい場合はScriptingページを参照してください。

Customize Toolbars This way you can make your macro become a real tool, just like any standard FreeCAD tool. This, added to the power of python scripting within FreeCAD, makes it possible to easily add your own tools to the interface. Read on to the Scripting page if you want to know more about python scripting...

記録せずにマクロを作成する

また、直接GUI操作を記録せずに、マクロにpythonコードをコピー/ペーストすることができます。新しいマクロを作成・編集して、コードを貼り付けます。あなたのマクロはFreeCADの文書を保存するのと同じ方法で保存することができます。FreeCADを次回起動する時には、マクロは「Macro」メニューの"Installed Macros"項目の下に表示されます。

Macros repository

Visit the Macros recipes page to pick some useful macros to add to your FreeCAD installation.

Links

Installing more workbenches

Tutorials

How to install additional workbenches

Standard Menu
Introduction to Python