Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. Cairyn
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Cairyn

    @Cairyn

    124
    Reputation
    245
    Posts
    339
    Profile views
    3
    Followers
    0
    Following
    Joined Last Online

    Cairyn Follow

    Posts made by Cairyn

    • RE: Python and the GUI Separator

      @m_magalhaes said in Python and the GUI Separator:

      Of course, opportunity to have a better documentation is more than welcome.
      that allow us to track things and add them in our changelogs.

      okay... (everything here is for the Python doc page for GeDialog, unless specified differently)

      • The first one would be a line that I believe to be erroneous but maybe there's a secret functionality behind it that I don't get: Both GeDialog.AddRadioButton and GeDialog.AddRadioText have the note Used with radio groups created with AddRadioGroup(). However, there is no way to connect these controls with a radio group. Radio groups only accept AddChild entries, and AddChild cannot refer another control as subid. (id can be a C4DGadget but subid can not.) The calls AddRadioButton/Text do not allow to specify a radio group as parent. So, unless there is an undocumented trick, this note may be wrong.
        (To use RadioButton and RadioText, I handle the clicks myself in the Command method, and deselect the complementary controls.)

      • The screenshot under AddColorField belongs actually to AddColorChooser.

      • Not an error, but it would be nice to mention under GeDialog.AddDlgGroup that DLG_OK and DLG_CANCEL are not just the flags for type, but also serve as IDs for the buttons that can be evaluated in the Command method. I think it's unusual to have bitset flags at the same time as result integers (even in C4D: the MessageDialog has GEMB_xxx values as boole-combineable flags, but separate GEMB_R_xxx constants as results) so it bears mentioning.

      • GeDialog.AddSlider tells us Adds a slider with an editable number field to the layout. which is apparently copied from AddEditSlider, as AddSlider does not have a number field.

      • GeDialog.AddChildren - what's supposed to be in the BaseContainer bc? I originally assumed you could use it like this:

      self.AddRadioGroup(ID_RADIO_MAIN, flags = c4d.BFH_LEFT, columns = 1)
      r1 = self.AddRadioText(id=ID_RADIO_4, flags=c4d.BFH_SCALEFIT, name="A radio text")
      r2 = self.AddRadioText(id=ID_RADIO_5, flags=c4d.BFH_SCALEFIT, name="Radio text 2")
      r3 = self.AddRadioText(id=ID_RADIO_6, flags=c4d.BFH_SCALEFIT, name="RT3")
      bc = c4d.BaseContainer()
      bc.SetData(ID_RADIO_4, r1)
      bc.SetData(ID_RADIO_5, r2)
      bc.SetData(ID_RADIO_6, r3)
      self.AddChildren(ID_RADIO_MAIN, bc)
      

      but SetData raises an error. As a BaseContainer is a C++ structure and r1 is a Python data, I come to doubt that would even be possible, so perhaps AddChildren is limited to ID / string combinations, which actually do work:

      self.AddRadioGroup(ID_RADIO_MAIN, flags = c4d.BFH_LEFT, columns = 1)
      bc = c4d.BaseContainer()
      bc.SetData(ID_RADIO_4, "Text1")
      bc.SetData(ID_RADIO_5, "Text2")
      bc.SetData(ID_RADIO_6, "Text3")
      self.AddChildren(ID_RADIO_MAIN, bc)
      

      May be useful to document that explicitly. The C++ page for the same command also says nothing on the subject.

      • GeDialog.GroupBegin What is the difference between BFV_GRIDGROUP_EQUALCOLS - Each column has the same width and BFV_CMD_EQUALCOLUMNS Columns have equal width ? I couldn't get the second one to work. Deprecated?

      Okay, that's what I noticed while working through the GeDialog page. I skipped a lot so there may be other open issues.

      posted in Cinema 4D Development
      Cairyn
    • RE: Python and the GUI Separator

      Ah, I see, inith in AddSeparatorH is actually a width value, and since flags defaults to BFH_FIT, you cannot see any effect since the control adapts the full width. And since the function doesn't accept an initw or initv parameter, there is no height control at all.

      And since AddSeparatorV is calling up a horizontal line, I can't expect correct results anyway.

      Thanks for the info.
      (btw, there are multiple copy&paste errors in the GeDialog doc, shall I send you some? Not serious enough for a full bug report, but...)

      posted in Cinema 4D Development
      Cairyn
    • Python and the GUI Separator

      Hello, I found a dubious detail in the function GeDialog.AddSeparatorH()...

      The Python header shows the parameter list as
      GeDialog.AddSeparatorH(self, inith, flags=BFH_FIT)
      But if you set inith to anything, the height of the separator stays the same... no effect at all. (Nevertheless it's a mandatory parameter.)
      In the parameter list below, that parameter suddenly becomes
      initw (int) – Initial width.
      No inith is listed... but initw is not accepted as parameter.

      So I looked at the C++ documentation... and find initw:
      initw The initial width. Use SizePixChr() to set this value.

      The Python doc for AddSeparatorV contains an initv in both header and parameter list (I didn't check whether it has any effect) but an inith in the C++ docs.

      So, what is correct? And if inith is the only accepted parameter, why doesn't it do anything?

      (And not to be picky, but the Python doc screenshot snippet for AddSeparatorV shows the horizontal separator again. 😊 )

      posted in Cinema 4D Development
      Cairyn
    • RE: How to find an object quickly?

      Considering that a UniqueID has to be registered with Maxon, this may not be the way to identify arbitrary objects within the object tree?
      Seems to depend on the actual usecase. What is the final purpose here?

      posted in Cinema 4D Development
      Cairyn
    • RE: How to find an object quickly?

      @chuanzhen Not that I know of, since these are not links from some internal cache. You may need to write your own function to traverse the tree and compare manually.
      Unless some Maxon person knows a better way.

      posted in Cinema 4D Development
      Cairyn
    • RE: How to find an object quickly?

      Try BaseObject.GetGUID().

      posted in Cinema 4D Development
      Cairyn
    • RE: [SOLVED/NotABug] Bug with c4d.CPolygon

      E.g.: You can always compute the arithmetic mean of the vertices of a Cpolygon by computing (pnts[cpoly.a] + pnts[cpoly.b] + pnts[cpoly.c] + pnts[cpoly.d]) * .25, without having to worry if it is a tri or quad.

      I tend to disagree here. In a triangle, the arithmetic center should only consider the first three vertices. Doubling the last vertex leads to a different (weighted) result. E.g. reduced to one axis:

      1 + 2 + 9 = 12, divided by 3 results in 4
      1 + 2 + 9 + 9 = 21, divided by 4 results in 5.25

      posted in Cinema 4D Development
      Cairyn
    • RE: [SOLVED/NotABug] Bug with c4d.CPolygon

      @xNWP Yeah, a CPolygon is really just those four corner indices, a,b,c,d - there is no separate flag that would tell C4D whether this is a triangle or a quadrangle. The information what type of polygon the CPolygon is, is really only encoded in the equality c==d. The function IsTriangle could be written as

      def IsTriangle(self):
          return self.c == self.d
      

      I assume you have read
      https://developers.maxon.net/docs/Cinema4DPythonSDK/html/manuals/3d_concept/modeling/polygon_object.html#polygon-object
      already, although that doesn't go in depth into the triangle property.

      (It gets even better when you come to edge indices: a triangle has edges ab, bc, da - not cd obviously, but also not ca!)


      Learn more about Python for C4D scripting:
      https://www.patreon.com/cairyn

      posted in Cinema 4D Development
      Cairyn
    • RE: [SOLVED/NotABug] Bug with c4d.CPolygon

      Of course not. If you change the c attribute, then c will no longer be equal to d, and it becomes a quadrangle.

      To be more precise: A polygon object always has 4 corner points in form of point indices a,b,c,d. If the corners c and d are equal, then Cinema handles it as a triangle.

      In your code, you create a triangle by setting the corners to the points 0, 1, 2. Corner d will automatically also be 2, since you didn't specify otherwise (print Foo.d to verify). So actually you get the CPolygon (0,1,2,2). This is a triangle.

      Then you set c to 0, resulting in the CPolygon (0,1,0,2). This is a quadrangle (albeit a degenerated one). In your code, you comment # True but actually that's wrong, you get False. (I just tried.)

      Then you set c to 5, resulting in the CPolygon (0,1,5,2). This is a proper quadrangle.

      It would be easier to see if you had actual geometry attached to the points, instead of just having the indices.

      posted in Cinema 4D Development
      Cairyn
    • RE: Data to Spline

      Python can easily read lines from a file, split the line into partial strings, and convert the strings into float values.

      But for creating a spline from that, you will need to have a look at the class SplineObject and its parent PointObject:
      https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/PointObject/SplineObject/index.html?highlight=spline#c4d.SplineObject

      C++ would require the huge project overhead so I can't really recommend this for such a simple script.

      posted in Cinema 4D Development
      Cairyn