• Cinema4D Get Texture Atlas/Get Image At Coordinate

    python
    4
    1
    1 Votes
    4 Posts
    1k Views
    C
    Did GetClonePart and it works Cinema4D Preview Icon [image: 1584841017304-unknown.png] [image: 1584841026677-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)
  • Apply a step value in SetHandle function

    python
    4
    0 Votes
    4 Posts
    565 Views
    mfersaouiM
    @zipit Hi, Thank you.
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • MouseWheel different between R20 and R21

    3
    0 Votes
    3 Posts
    449 Views
    C4DSC
    @r_gigante Well ... this is embarrassing. I came up with the R21 code using notes I had collected over the years, and was rather confused seeing this didn't port over to R20. Actually the correct code should look like following: Bool MyUserArea::InputEvent(const BaseContainer& msg) { const Int32 dev = msg.GetInt32(BFM_INPUT_DEVICE); const Int32 chn = msg.GetInt32(BFM_INPUT_CHANNEL); if (dev == BFM_INPUT_MOUSE) { if (chn == BFM_INPUT_MOUSEWHEEL) { const Float wheel = msg.GetFloat(BFM_INPUT_VSCROLL) / 120.0; Int32 mx = msg.GetInt32(BFM_INPUT_X); Int32 my = msg.GetInt32(BFM_INPUT_Y); Global2Local(&mx, &my); ApplicationOutput("Mousewheel value @ at x=@, y=@", wheel, mx, my); return true; } } return false; } No need at all to perform a GetInputState to obtain the the x and y coordinates from, as the BaseContainer to get it from is already provided as "msg". And this works both for R21 and R20. Man ... sometimes you think you know what you're doing, and then it seems you just know squad. Embarrassing! Riccardo, terribly sorry for wasting your time!
  • Matrix.__mul__(self, other) documentation ambiguity

    python
    2
    0 Votes
    2 Posts
    257 Views
    r_giganteR
    Thanks a lot @zipit . I indeed agree and will update the documentation accordingly. Best and stay safe! R
  • How to open a GeDialog Modal to default width & height?

    python sdk
    5
    1
    0 Votes
    5 Posts
    687 Views
    ?
    @m_magalhaes Thank you for this workaround. I hope to see that bug fixed soon! It seems like one that would affect many scripts & plugins.
  • 0 Votes
    4 Posts
    777 Views
    ManuelM
    hi, I think you have access to the beta and BL so you can create a suggestion Cheers, Manuel
  • Assets Management

    5
    0 Votes
    5 Posts
    694 Views
    RenatoTR
    Ok, i solved my problem was my miss. Thanks again.
  • SplineHelp GetPosition Deformation

    r20 c++ sdk
    3
    1
    0 Votes
    3 Posts
    629 Views
    J
    Thanks for the response, that's exactly what I needed. John Thomas
  • ParallelFor: TestBreak()

    c++ r20 r21
    7
    0 Votes
    7 Posts
    681 Views
    ManuelM
    hi, as @PluginStudent said i was using GeGetEscTestThread and by the way, it's not really working But that's the same question with your code. You test the thread that have been provided to you or your own thread. For that you pass that thread as a reference to the lambda function. Cheers, Manuel
  • Fun with maxon::BaseArray

    c++ r20 r21
    5
    0 Votes
    5 Posts
    700 Views
    r_giganteR
    I need to spend some further consideration since it looks like I was unprecise. When the BaseArray::Append() and the capacity of a BaseArray is reached - BaseArray default size is 16 elements - the internal BaseArray::IncreaseCapacity()is called and it sequentially allocates a new memory block, copies the values of the previous block to the new one, and then the old one is released. Being the values passed to the BaseArray::Append() a reference to myArray[0], it references the first element of the old block and because the code in Append() accesses the reference after the old block has been released, that access is illegal. @r_gigante said in Fun with maxon::BaseArray: To temporarily mitigate it you have to cast the value returned from the [] operator before appending it to the proper type. Actually by writing Int32(myArray[0]) - and here I was indeed unprecise because it is NOT casting but temporary local creating of a copy - a local Int32 copy of myArray[0] is made on the stack at first by the compiler (before calling Append) and then Append(Int32(myArray[0])) references that local copy which is legal. This behavior is NOT a bug - another initial overlook of mine - but rather a behavior by design which for example is also part of std::vector::push_back(). So, as a rule of thumb, cases where references to array elements are used while the array gets resized must be avoided. This note will be added to the BaseArray Manual in our documentation. Sorry for the confusion I initially generated and, if further clarification are needed, feel free to come back. R.
  • This topic is deleted!

    1
    2
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Force refresh Xpresso

    Moved python r21
    13
    1
    0 Votes
    13 Posts
    3k Views
    SwinnS
    Yes, Thanks.
  • 0 Votes
    6 Posts
    520 Views
    M
    Thanks Both of you @zipit @m_adam , Quote: "keep in mind coping data is expensive" I had the feeling that the very nice example I am building on has some limitations (speed) as you mentioned. I guess I have to re organice this section (selecting points) and clean up. My aproach as a beginner is more or less like this. try get it to work anyhow try to understand it by cleaning try to make a compact function so it doesn't break my code everytime i touch it ... I have an old C++ code as an cheat sheet to get a general idea how a perfomant code could look like (selecting & working just inside one big point object list, as far as I understand it) , but at this stage I can't combine them jet hence the different selecting aproach. Anyway I try to get somethingmore robust ... Thank you for your time. mogh
  • glTF Exporter

    2
    0 Votes
    2 Posts
    350 Views
    r_giganteR
    Hi Index, thanks for reaching out us. I confirm that the development is on supporting glTF is continuing. Stay tuned! Best, R
  • DistanceQuery

    c++ r20 sdk
    3
    0 Votes
    3 Posts
    488 Views
    N
    thank you so much!!
  • Create a circle with specific area size.

    python
    3
    0 Votes
    3 Posts
    578 Views
    mfersaouiM
    @PluginStudent Thank you.
  • Blit to MultipassBitmap GeClipMap not working

    r20 c++
    15
    0 Votes
    15 Posts
    2k Views
    C4DSC
    @r_gigante While doing some code cleanup to add new features to a plugin, I noticed some comments regarding this particular topic. The comment mentioned the need for a workaround since the Blit() functionality on Windows was faulty. Problem with Blit() and MultipassBitmap still occurs after switching to Visual Studio 2017, Windows 10, running R20.059
  • How to use STRINGTABLE with a Python Command Plugin

    sdk python
    7
    0 Votes
    7 Posts
    817 Views
    P
    I don't think there are any official "tools". But the docs describe how to handle unicode (Dialog Layout The encoding is 7-bit ASCII with other characters encoded as \uHHHH. For example 'Natürlich' is written 'Nat\u00fcrlich'. Byte-order marks are not used.
  • 0 Votes
    6 Posts
    753 Views
    D
    @m_magalhaes Thank you