• BaseBitmap.ScaleIt Documentation

    Cinema 4D SDK python
    3
    1 Votes
    3 Posts
    410 Views
    M
    Hi, This is solved in the last documentation update, see BaseBitmap.ScaleIt. Cheers, Maxime.
  • 0 Votes
    7 Posts
    1k Views
    ?
    @m_adam Thank you, Maxime, for going to this effort.
  • COLOR Constants Guide & Documentation Error

    Cinema 4D SDK python r21
    2
    1
    2 Votes
    2 Posts
    307 Views
    ManuelM
    Hello, thanks for sharing this with the everybody. COLOR_TIMELINE is now EX_COLOR_TIMELINE the documentation will be updated to reflect that change. Cheers, Manuel
  • 0 Votes
    3 Posts
    1k Views
    L
    Manuel, thanks for taking the time and posting some links. Last night I was reading up on the Matrix and trying wrapping my head around it. I think I was stuck in the wrong area, I was trying to convert a baseObject to a pointObject to do the transformations.I would perfer not to have to open the axis window, but instead handle all this in a Python Function. I will look over the docs and samples to get a better idea of what I need to do. Thanks again for taking the time to respond to my post!
  • Advice for storing animation in a Hyperfile

    Cinema 4D SDK python sdk
    4
    0 Votes
    4 Posts
    560 Views
    ?
    Additional information here: https://developers.maxon.net/forum/topic/12295/bug-with-getlink-setlink-hyperfile/3 Thank you @m_magalhaes & @r_gigante!
  • OperatorSetData for "Lists"?

    Cinema 4D SDK python r20
    5
    0 Votes
    5 Posts
    846 Views
    r_giganteR
    @esan said in OperatorSetData for "Lists"?: Another quick question. is there still a bug on c4d.GV_OBJECT_OPERATOR_OBJECT_OUT? Yes it's still there and being R20 maintenance ended it's likely to remain. Best, R
  • Get Objects from the Layer?

    Cinema 4D SDK r21 python
    4
    0 Votes
    4 Posts
    548 Views
    ferdinandF
    Hi, if I am not overlooking something here, the function recurse_hierarchy is neither recursive nor will it retrieve the layers for all objects in the scene. It will retrieve the layers for all siblings of the passed node, that were born after that node. You probably made a mistake copying your code or misunderstood what is meant by recursive. Cheers, zipit
  • How to set completely custom render output filename?

    Cinema 4D SDK python
    6
    0 Votes
    6 Posts
    2k Views
    r_giganteR
    @jcooper said in How to set completely custom render output filename?: How do I control how much zero-padding is used for the $frame token? We typically use 4-digit, zero-padded frame tokens, but what if a situation called for, say, 6 digits? Hi John, with regard to the $frametoken the zero-padding is hardcoded but as stated by @zipit you can workaround it by registering your token (see here) . How do I get at the RenderData for a specific renderer such as Redshift? For instance, it has its own "filename" attribute, but I don't know how to access/modify it from the python API. You need to retrieve the RedShift BaseVideoPost and retrieve the corresponding data from its BaseContainer. Check the code below # Get the active RenderData renderData = doc.GetActiveRenderData() if renderData is None: raise RuntimeError("Failed to retrieve the render data.") # Get the active render settings renderSettings = renderData.GetData() if renderSettings is None: raise RuntimeError("Failed to retrieve the render settings.") # Get the first video post videopost = renderData.GetFirstVideoPost() if videopost is None: raise RuntimeError("Failed to retrieve the videopost associated with the render data.") # Search for the RedShift videopost while videopost is not None and videopost.GetType() != 1036219: print "RedShift is not set as renderer in the active RenderData, check next" videopost = videopost.GetNext() rsAOV = None # Retrieve the AOV -> Filname param value if videopost is not None and videopost.GetType() == 1036219: rsAOV = videopost[c4d.REDSHIFT_RENDERER_AOV_PATH] # Reads the path stored in the render setting path = renderSettings[c4d.RDATA_PATH] # Add token to the path path = path + rsAOV # Tokenizes the path from the render engine rpd = {'_doc': doc, '_rData': renderData, '_rBc': renderSettings, '_frame': 1} exclude = [] finalFilename = c4d.modules.tokensystem.FilenameConvertTokensFilter(path, rpd, exclude)+".png" print finalFilename
  • Creating Keyframes with AutoKey

    Cinema 4D SDK python sdk
    4
    0 Votes
    4 Posts
    986 Views
    M
    Hi @blastframe this is also the behavior of AutoKey in the Editor, so I would say is not an API issue. But you can use BaseDocument.Record to simulate the click of AddKeyFrame (but of course correct parameter have to be checked). Cheers, Maxime.
  • Create BaseBitmap() from Text?

    Cinema 4D SDK r21 python
    5
    0 Votes
    5 Posts
    522 Views
    B
    @m_adam Thanks for the response. For some reason, the return value is not accepted by the SetFont. It does not error out. It just uses the default font. In addition, how were you able to determine that the [508] is for the font name? I can't seem to see such reference in the documentation. You can check the working code here: import c4d from c4d import gui # Welcome to the world of Python def GetSegoeUiBoldFont(): bcFonts = c4d.bitmaps.GeClipMap.EnumerateFonts(c4d.GE_CM_FONTSORT_HIERARCHICAL) for familyId, familyBc in bcFonts: for fontDescriptionId, fontDescription in familyBc: if fontDescription[508] == "SegoeUI-Bold": return fontDescription print fontDescription def main(): w = 50 h = 50 image_with_text = c4d.bitmaps.GeClipMap() image_with_text.Init(w=w,h=h,bits=32) image_with_text.BeginDraw() image_with_text.SetColor(125,255,255) image_with_text.FillRect(x1=0,y1=0,x2=50,y2=50) image_with_text.SetColor(0,0,0) font_bc = GetSegoeUiBoldFont() print font_bc font_size = 15 image_with_text.SetFont(font_bc,font_size) image_with_text.TextAt(x=10,y=15,txt='head') image_with_text.EndDraw() bmp = image_with_text.GetBitmap() c4d.bitmaps.ShowBitmap(bmp) # Execute main() if __name__=='__main__': main()
  • Dialog Freezes when checking for Message()

    Cinema 4D SDK r21 python
    12
    0 Votes
    12 Posts
    1k Views
    B
    Thanks @m_adam. First time using the c4d.DrawViews(). It works as expected. Thanks for the introduction.
  • Get the Button GadgetID Directly Under the Mouse?

    Cinema 4D SDK r21 python
    11
    0 Votes
    11 Posts
    2k Views
    B
    Hi @m_adam Thanks for the patience. Your suggestions and reminders works are greatly appreciated. I guess the confusion stems mainly on my part because I posted slightly two different codes. You were responding to my initial post but I was thinking with the code from the succeeding post(the one in the rar file). Totally my bad. Anyhow, here is the working code (using the initial post) which works as I expected: import c4d class ColorButton(object): def __init__(self): self.width = None self.height = None self.color = None self.color = None self.btn_id = None self.menu_list = None def create(self, dlg, w, h, color, btn_id): self.width = w self.height = h self.color = color self.btn_id = btn_id bmp_color = c4d.bitmaps.BaseBitmap() bmp_color.Init(w, h) for y in xrange(w): for x in xrange(h): bmp_color.SetPixel(x, y, color[0], color[1], color[2]) bcBitmapButton = c4d.BaseContainer() bcBitmapButton[c4d.BITMAPBUTTON_BUTTON] = True bmp_btn = dlg.AddCustomGui(self.btn_id, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, w, h, bcBitmapButton) bmp_btn.SetImage(bmp_color, True) def create_menu(self): self.menu = c4d.BaseContainer() for menu_item in self.menu_list: counter = 0 IDM_MENU = c4d.FIRST_POPUP_ID + counter self.menu.InsData(IDM_MENU, menu_item) counter += 1 class MyDialog(c4d.gui.GeDialog): def __init__(self): self.btn_id_list = [] self.class_btn_id_dict = {} def CreateLayout(self): red_button = ColorButton() red_button.create(self, w=50,h=50,color=(255,0,0), btn_id=6000) red_button.menu_list = ['Menu1', 'Menu2', 'Menu3'] self.btn_id_list.append(red_button.btn_id) self.class_btn_id_dict[6000] = red_button blue_button = ColorButton() blue_button.create(self, w=50,h=50,color=(0,0,255), btn_id=7000) blue_button.menu_list = ['Menu4', 'Menu5', 'Menu6', 'Menu7'] self.btn_id_list.append(blue_button.btn_id) self.class_btn_id_dict[7000] = blue_button green_button = ColorButton() green_button.create(self, w=50,h=50,color=(0,255,0), btn_id=8000) green_button.menu_list = ['Menu8', 'Menu9'] self.btn_id_list.append(green_button.btn_id) self.class_btn_id_dict[8000] = green_button return True def IsPositionOnGadget(self, gadgetId, x, y): # Be sure that the windows is opened, # in our case since we call it in BFM_INTERACTSTART it's ok buttonData = self.GetItemDim(gadgetId) if not buttonData["x"] < x < buttonData["x"] + buttonData["w"]: return False if not buttonData["y"] < y < buttonData["y"] + buttonData["h"]: return False return True def function_to_determine_gadgetId_under_mouse_cursor(self, x, y): for gadgetId in self.btn_id_list: if self.IsPositionOnGadget(gadgetId, x, y): return gadgetId def Message(self, msg, result): if msg.GetId() == c4d.BFM_ADJUSTSIZE: self._x = msg[3] # Retrieve Y size of the GeDialog self._y = msg[4] # Retrieve Y size of the GeDialog # We are on the main thread here elif msg.GetId() == c4d.BFM_INTERACTSTART: c4d.StopAllThreads() state = c4d.BaseContainer() self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSERIGHT, state) if state.GetInt32(c4d.BFM_INPUT_VALUE) == True: x = state.GetInt32(c4d.BFM_INPUT_X) y = state.GetInt32(c4d.BFM_INPUT_Y) g2l = self.Global2Local() x += g2l['x'] y += g2l['y'] gadgetId = self.function_to_determine_gadgetId_under_mouse_cursor(x=x,y=y) if gadgetId in self.btn_id_list: if self.IsPositionOnGadget(gadgetId=gadgetId, x=x, y=y): button_class = self.class_btn_id_dict[gadgetId] button_class.create_menu() l2s = self.Local2Screen() print str(x+l2s['x']) + " :: " + str(y+l2s['y']) self.KillEvents() res = c4d.gui.ShowPopupDialog(cd=self, bc=button_class.menu, x=x+l2s['x'], y=y+l2s['y']) return True return c4d.gui.GeDialog.Message(self, msg, result) if __name__ == "__main__": dlg = MyDialog() dlg.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=20304050)
  • 0 Votes
    8 Posts
    1k Views
    B
    Ok. I figured it out. The ID was wrong. It was supposed to be 465001634 -b
  • Identify when scene is rendering (Redshift)

    Cinema 4D SDK python
    6
    0 Votes
    6 Posts
    1k Views
    rsodreR
    @wen I was trying to do the same the past days. I could'nt figure out how to detect if Redshift IPR is enabled, but I found some relevant RS Ids. The 1038666 command opens the IPR window, but as far as I know there's no way to get the dialog instance to call IsOpen() The 1036752 CoreMessage is sent during IPR renders, but without any additional parameters (PAR1/PAR2). Not sure if there's something else we can extract from that message. What I ended up doing is adding a bool to my plugin to enable IPR features, but would be good to enable automatically.
  • Undo for GeDialog (GUI)?

    Cinema 4D SDK r21 python
    4
    0 Votes
    4 Posts
    509 Views
    B
    @blastframe @m_magalhaes Thanks for the response and the confirmation that Undo is not included in the GeDialog(GUI). That said the supplied code works on my use case. Thanks again!
  • Issue with registering a ToolData

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    637 Views
    a_blockA
    Hi Maxime, thanks a lot! Both are valid solutions for me. Very helpful. Cheers
  • Quick Tab Radio for GeDialog?

    Cinema 4D SDK r21 python
    4
    0 Votes
    4 Posts
    683 Views
    B
    @r_gigante Thank you for the response and especially for the alternative code (first time to see a line with msg[c4d.BFM_ACTION_VALUE]. Both code works as expected.
  • Add Commands to ShowPopupDialog

    Cinema 4D SDK r21 python
    7
    0 Votes
    7 Posts
    1k Views
    B
    @m_adam Thanks for further clarification. @Ashton_FCS_PluginDev 's code works but I guess I'll just use the result of the ShowPopupDialog to trigger commands, as I added in the previous code.
  • Creating Class for Buttons Returns None

    Cinema 4D SDK r21 python
    5
    0 Votes
    5 Posts
    534 Views
    B
    @m_adam Ah. Gotcha. Thanks for the clarification and link.
  • Get mode (object, face, edge, point) with python

    Cinema 4D SDK python
    4
    1
    0 Votes
    4 Posts
    749 Views
    W
    Thanks Sebastian.