Did GetClonePart and it works 🙂
Cinema4D Preview
Icon
unknown.png
demoIcons.png
[CODE HERE]
# // Imports //
import os
import sys
# // Imports for Cinema 4D //
import c4d
from c4d import plugins, gui, bitmaps, documents, storage, utils
# Icons Image Paths
OneImageIcons = os.path.join(os.path.dirname(__file__), 'icons', "demoIcons.png")
# ---------------------------------------------------------------------
# Creating GUI Instance Functions UI Elements Operations
# Hepler Methods.
# ---------------------------------------------------------------------
# Get Icon from Icons one image.
def GetCustomIcon(size, locCordX, locCordY):
""" Get Texture Atlas Image """
bmp = c4d.bitmaps.BaseBitmap()
bmp.InitWith(OneImageIcons)
w = size
h = size
x = locCordX
y = locCordY
selectIcon = bmp.GetClonePart(x, y, w, h)
return selectIcon
# Create a Bitmap Button Custom GUI.
def CustomImageButton_GUI(ui_ins, btn_id, toolname, tooltip, image):
ui_ins.GroupBegin(0, c4d.BFH_MASK, 1, 0, "")
bc = c4d.BaseContainer() # Create a new container to store the button image
bc.SetLong(c4d.BITMAPBUTTON_BORDER, c4d.BORDER_NONE) # Sets the border flag to look like a button look. eg.( c4d.BORDER_NONE or c4d.BORDER_THIN_OUT or c4d.BORDER_OUT )
bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True) # Clickable button / Does not seem to to work in R13?
bc.SetBool(c4d.BITMAPBUTTON_TOGGLE, True) # Toggle button, like a checkbox.
bc.SetString(c4d.BITMAPBUTTON_TOOLTIP, "<b>"+ toolname + "</b><br>" + tooltip)
ui_ins.myBitButton = ui_ins.AddCustomGui(btn_id, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_MASK, 10, 10, bc)
ui_ins.myBitButton.SetImage(image)
ui_ins.GroupEnd()
return True
# ----------------------------------------
# // UI Main Window //
# ----------------------------------------
class Tool_WindowDialog(c4d.gui.GeDialog):
# GUI Ids
IDS_VER = 999
IDS_OverallGrp = 1000
IDS_StaticText = 1001
IDS_BTN_01 = 1002
IDS_BTN_02 = 1003
IDS_BTN_03 = 1004
IDS_BTN_04 = 1005
# // Main GeDialog Overrides //
"""
The __init__ is an Constuctor and help get
and passes data on from the another class.
"""
def __init__(self):
super(Tool_WindowDialog, self).__init__()
# UI Layout
def CreateLayout(self):
# Dialog Title
self.SetTitle("Tool Ui")
# Adding the GUI Buttons and inside a empty group with 4 rows.
self.GroupBegin(0, c4d.BFH_SCALEFIT, 4, 0, "")
self.GroupBorderSpace(5, 5, 5, 5)
CustomImageButton_GUI(ui_ins=self,
btn_id=self.IDS_BTN_01,
toolname="Go UP",
tooltip="HelloWorld",
image=GetCustomIcon(size=32, locCordX=0, locCordY=37))
CustomImageButton_GUI(ui_ins=self,
btn_id=self.IDS_BTN_02,
toolname="Go Right",
tooltip="HelloWorld",
image=GetCustomIcon(size=32, locCordX=0, locCordY=0))
self.GroupEnd()
self.GroupEnd() # End of the overall group.
return True
# Called when the dialog is initialized by the GUI / GUI's with startup values basically.
def InitValues(self):
print("Yang Ultimate Tools Dialog is open.")
return True
# Adding Excuting Commands Functions for UI Elements.
def Command(self, id, msg):
if id == id:
print(str(id))
return True
# Override this function if you want to react to Cinema 4D core messages.
# The original message is stored in msg
def CoreMessage(self, id, msg):
if id == c4d.EVMSG_CHANGE:
#self.add_images()
pass
return True
"""
DestroyWindow Override this method - this function is
called when the dialog is about to be closed temporarily,
for example for layout switching.
"""
def DestroyWindow(self):
print("Tools Dialog Close.")
if __name__=='__main__':
class_dialog = Tool_WindowDialog()
class_dialog.Open(c4d.DLG_TYPE_ASYNC, defaultw=200, defaulth=10)