Jump to content

Generating Number Sequences Using MoGraph with "00" before numbers


LightCacher
Go to solution Solved by jed,

Recommended Posts

Hi all!

I have a little problem with the mograph blend mode. As you can see in the screenshot, I want to number my cabinets with numbers from 001 to 150. With mograph I have succeeded but I cannot start with "001" instead "1" as the numbers in black. Is there any way to do it?

Thanks all

01.jpg

Link to comment
  • Solution

Assuming you're using Noseman's method of getting the text from the name, it's possible if you use python zfill and make the cloner editable -

 

zfill.png.5521c82bbe09c63e6f1a595d2499e308.png

 

import c4d
#Welcome to the world of Python


def main():
    global Output1
    Output1 = Input1.zfill(3)

 

zfill pads a string with zeros up to the max character count in brackets.

 

zfill.c4d

 

Noseman's method - Generating Number Sequences Using MoGraph in Cinema 4D - YouTube

Link to comment
1 hour ago, jed said:

Assuming you're using Noseman's method of getting the text from the name, it's possible if you use python zfill and make the cloner editable -

 

zfill.png.5521c82bbe09c63e6f1a595d2499e308.png

 


import c4d
#Welcome to the world of Python


def main():
    global Output1
    Output1 = Input1.zfill(3)

 

zfill pads a string with zeros up to the max character count in brackets.

 

zfill.c4d 640.45 kB · 1 download

 

Noseman's method - Generating Number Sequences Using MoGraph in Cinema 4D - YouTube

 

Unfortunately I don't know python..and dont't what do you do but it works! Thanks a lot!

Link to comment
1 hour ago, LightCacher said:

Unfortunately I don't know python.

Here's your 1st lesson 😀

 

I made a python node and deleted the ports (by default they are reals and Python is quite fussy about data types)

I made input and output ports data type string

code to be executed goes under def main(): and is indented by 4 spaces

the output variable is declared global so it can exist outside the main code body (where variables are local)

the = sign works a bit different to regular math. The RHS is evaluated and assigned to the LHS variable - Output1 is 'given' that value

zfill is a built in string command

 

the = sign malarkey is interesting because you can have apparently nonsense Python code such as

 

x = x + 1

 

which just increments x by 1

Link to comment
  • 1 month later...
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • LATEST ACTIVITIES

    1. 10

      CORE 4D Youtube channel

    2. 10

      CORE 4D Youtube channel

    3. 16

      3D world #310

    4. 53

      Looking forward to the next C4D release

    5. 10

      CORE 4D Youtube channel

×
×
  • Create New...

Copyright Core 4D © 2023 Powered by Invision Community