Wrangle x Python book I tried it [1]

What is this?

Distributed at COMITIA115 (2016/01/31 at Tokyo Big Sight) ** Houdini Practical Handbook Wrangle x Python ** (Circle "Magic Distilled Water") http://majou.jp/archives/667/

This is a memo when I tried to work on a Python example sentence.

p.10 "3 Wrangle x Python practice" 3.1 Point movement

Preparation

New scene → geometry node creation geo1.png

Once inside (delete the original file1) Create grid Create python Connect gridWithPy.png

setPosition() The example sentence on p.10. I will write in the Python Code column in the Python node code01.png

The first two lines were written when the Python node was created, so Only the next 4 lines. (* The first two lines are described on p.6)

python


for point in geo.points():
    pos = point.position()
    pos += hou.Vector3(0,2,0)
    point.setPosition(pos)

This is the only secret that I typed the points of geo.points () to the point and became "Are".

result result01.png I moved 2 in the Y direction.


I also rewrite it as follows and play

Rewrite 1


for point in geo.points():
    point.setPosition( point.position()+hou.Vector3(0,2,0) )

Rewrite 2


x = 0
y = 2
z = 0
pos = hou.Vector3(x,y,z)

for point in geo.points():
    point.setPosition( point.position()+pos )

hmath.buildTranslate

p.10 Second example sentence

python


for point in geo.points():
    pos = point.position()
    mtx = hou.hmath.buildTranslate((0,2,0))
    pos = pos * mtx
    point.setPosition(pos)

result02.png

pos = pos * mtx can be an assignment operator. pos * = mtx

Summary

For the time being, only the Python example sentences on p.10.

Wrangle x Python book, Toranoana seems to be orderable https://www.toranoana.jp/mailorder/article/04/0030/38/99/040030389986.html ~~ It seems to be scarce ~~ <When I confirmed it at the timing of writing [2], it was sold out!

Remarks

Suggestion

Input completion appears in the middle of typing, such as around hou.hmath.b

suggest.png

Function description

When you start typing the function arguments, you will see a description of the function.

guide.png

print and help

If you put print orhelp ()in Python Code It will be displayed in a separate window called ** "Houdini Console" **. console.png

Please note that if there are too many lines, it will flow. For example, the above figure is an example when help (hou.hmath) is done, but the beginning part flowed and could not be read. (As expected, help is in Python Shell ~)

reference

Vector3 http://sidefx.jp/doc/hom/hou/Vector3.html

Matrix4 http://sidefx.jp/doc/hom/hou/Matrix4.html

setPosition http://sidefx.jp/doc/hom/hou/Point.html#setPosition

hmath http://sidefx.jp/doc/hom/hou/hmath.html

Since the published Japanese documents are not translated into Japanese unexpectedly, it is often quick to go to the head family quietly.


By the way, about Houdini's Python environment I also touched a little here

Python interpreter in Maya, Houdini, blender, Nuke http://qiita.com/it_ks/items/ae1d0ae01d831c2fc9ae#houdini

Recommended Posts

Wrangle x Python book I tried it [2]
Wrangle x Python book I tried it [1]
I tried Python> autopep8
I tried Python> decorator
I tried fp-growth with python
I tried scraping with Python
I tried Python C extension
[Python] I tried using OpenPose
AWS Lambda now supports Python so I tried it
I tried gRPC with Python
I tried scraping with python
I tried to touch Python (installation)
I tried web scraping with python.
I tried using Thonny (Python / IDE)
I tried Grumpy (Go running Python).
I tried running prolog with python 3.8.2.
I tried Line notification in Python
I tried SMTP communication with Python
[Python] I tried using YOLO v3
I tried to solve the ant book beginner's edition with python
I tried ChatOps with Slack x API Gateway x Lambda (Python) x RDS
I tried to summarize Python exception handling
I tried to implement PLSA in Python
I tried to implement permutation in Python
I installed DSX Desktop and tried it
I tried scraping Yahoo News with Python
I tried to implement PLSA in Python 2
I tried using Bayesian Optimization in Python
I tried non-photorealistic rendering with Python + opencv
I tried using UnityCloudBuild API from Python
I tried to implement ADALINE in Python
I tried a functional language with Python
I tried recursion with Python ② (Fibonacci sequence)
I tried to implement PPO in Python
Python: I tried the traveling salesman problem
Mayungo's Python Learning Episode 8: I tried input
[Python] I tried to calculate TF-IDF steadily
I tried scraping Yahoo weather (Python edition)
I tried to touch Python (basic syntax)
CheckIO (Python)> Non-unique Elements> I implemented it
I tried the Python Tornado Testing Framework
#I tried something like Vlookup with Python # 2
When I tried to run Python, it was skipped to the Microsoft Store
I tried to imitate Python x Kivy de Kinoppy (Kinokuniya bookstore app)
[Zaif] I tried to make it easy to trade virtual currencies with Python
[Python / DynamoDB / boto3] List of operations I tried
I tried "smoothing" the image with Python + OpenCV
I tried hundreds of millions of SQLite with python
[Python] I tried substituting the function name for the function name
I tried web scraping using python and selenium
I tried scraping
I tried object detection using Python and OpenCV
I tried PyQ
I tried playing a typing game in Python
When I try matplotlib in Python, it says'cairo.Context'
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
I started python
I tried Python! ] I graduated today from "What is Python! Python!"!
I tried L-Chika with Raspberry Pi 4 (Python edition)
When I tried to create a virtual environment with Python, it didn't work