The Python SDK & Hair

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/12/2011 at 15:08, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   Python 
Platform:      
Language(s) :

---------
HairGuides.SetPoint(id, p) has the same explanation as GetPoints()
"Gets a list of points for the guides."
This is of course wrong.

HairGuides.GetPoints() is also listed twice in the R13 sdk.

Concerning the rest of the SDK and Hair. There's not much there.
There isn't even an explanation on how to create hair objects and guides.
So here's an example I put together:

import c4d  
  
def main() :  
  
  obj = c4d.BaseObject(c4d.Ocube)             #Creates a Cube in memory only  
  doc.InsertObject(obj)                       #Adds it to the OM   
  ho = c4d.BaseObject(1017305)                #Creates a hair object in memory only  
  ho[c4d.HAIRSTYLE_LINK]= obj                 #Puts the cube into the hair's link field  
  doc.InsertObject(ho)                        #Adds it to the OM  
  c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK) #forces redraws  
  
  ho = doc.SearchObject("Hair")               #Lost the focus upon creation so we need to get it again  
  guides = ho.GetGuides()                     #Assign the guides to a variable  
  
  gcount = guides.GetCount()                  #Gets the number of guides  
  print gcount  
  
  segcount = guides.GetSegmentCount()         #Number of segments per guide (number of points is one more than this)  
  print segcount  
  
  gpcount = guides.GetGuidePointCount()       #Gets the number of points per segment.  
  print gpcount  
  
  owner = guides.GetObject()                  #Gets the guides owner object  
  print owner.GetName()  
  
  pnts = guides.GetPoints()                   #Gets a list of the points on all of the guides.  
  print pnts  
  
  guides.SetPoint(17, p= c4d.Vector(0,500,0)) #Moves one of the hair points to this vector position  
  ho.SetGuides(guides,clone=False)            #Error:The object doesn't own the guides!! Really?..Then who does?   
  
  c4d.EventAdd()  
  
if __name__=='__main__':  
  main()

I'm not sure what's going on with the SetGuides() function.
In C++ the hair object owns the guides. And the python SDK also says the same thing.
Yet I get an error that the hair object doesn't own the guides in my code.:dizzy_face:
I'm not sure if that's a real bug. Or another one of those things that's documented clearly.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/12/2011 at 23:29, xxxxxxxx wrote:

Hi, the guides already belong to the hair object. Cheers, Sebastian

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/12/2011 at 08:22, xxxxxxxx wrote:

Hi Sebastian,

That's kinds of a strange error message. It might be better to change it if possible.
So does that mean that SetGuides() is only supposed to be used within python plugins?

Also.
When I change a guide hair's point position with: guides.SetPoint(17, p= c4d.Vector(0,500,0)).
The point doesn't move(update) until I toggle the hair on&off in the OM.
I've tried things like: c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) but none of them are working for me.

-ScottA