A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
Numpy for Python Script
Posted: 30 November 2016 04:45 PM   [ Ignore ]  
Total Posts:  5
Joined  2016-05-10

Hi,

I’m just learning my way around in C4D and was attempting to write a python script to calculate the distance between two points.  I was surprised to find how tricky it was to code the math without the python numpy module which specializes in vectors and matrix calculations. 

Here is the line of code I would like to include in my script:

WhlBsDstnc np.linalg.norm(drvrFrntWhlgp-drvrBckWhlgp

Doing some on-line research I found this thread on the development support forum:
http://www.plugincafe.com/forum/forum_posts.asp?TID=12425&PN=1

After attempting ScottA’s “Anaconda swap solution” and some of the steps outlined by Niklas in his “compiled binaries” solution I have come up empty handed.

It seems severely restricting not having access to the numpy module. 

Is there any help to be had?  How can I access numpy from my C4D python scripts?

Thanks,

Thom

Profile
 
 
Posted: 30 November 2016 04:57 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Thom,

I’m not a coder and the Plug-In-Cafe is the place that MAXON provides for this.

http://www.plugincafe.com/forum/forum_posts.asp?TID=12425

I consider that the module is installed on your computer, then:

import numpy

Have you checked out the utils in the Cinema 4D SDK?

https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.utils/index.html


Edit: You might know it, but since I write in a forum, I deliver typically more data, as the variety of skills varies among all members, certainly in terms of Python:
https://docs.python.org/2/library/math.html
which would be
import math
/edit.

All the best and enjoy exploring Python.

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 01 December 2016 03:44 AM   [ Ignore ]   [ # 2 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

P.S.:

Here is a Python script (again, I’m not a coder, and I say this in respect of professional coders).

This could be shorter, but for the sake of a clear flow… have a look.

The clip is one minute long.
https://www.amazon.com/clouddrive/share/ZlHD3oo8ig8KPnpkwxlPIA9U3fRdOMiKtodW1SKknNs?ref_=cd_ph_share_link_copy

Take the Pythagoras: square root out ((x to the power of 2) + (y to the power of two) + (z to the power of 2))
The x; y; z values are int the off part of the Matrix. Here the distance of x, y and z is used.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile