Conveert Hair object to Polygon object
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/05/2012 at 07:56, xxxxxxxx wrote:
Hi all hope your haveing a good day right i want to make edible a hair object i know how to make a Opolygon object edible as in the script below what do i need to do to change it to make hair object edible cheers in advance.
def MakeEditable(op) :
if (not op) | op.CheckType(c4d.Opolygon) | op.CheckType(c4d.Ospline) : return op
op = [op.GetClone()]
doc = c4d.documents.BaseDocument()
doc.InsertObject(op[0],None,None)
op = c4d.utils.SendModelingCommand(
command = c4d.MCOMMAND_MAKEEDITABLE,
list = op,
mode = c4d.MODELINGCOMMANDMODE_EDGESELECTION,
doc = doc )
return op[0]
Thank you Ray. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/05/2012 at 15:02, xxxxxxxx wrote:
The hair ID's are found in: ..\..\..\..\modules\hair\res\description\ohair.h
Grab your hair object like any other object. Then use those ID's to change the attributes of the hair object as desired.import c4d from c4d import utils def main() : obj = doc.GetActiveObject() #Your hair object obj[c4d.HAIRSTYLE_GENERATE] = c4d.HAIRSTYLE_GENERATE_SPLINE #Use which option you want bc = c4d.BaseContainer() convert = utils.SendModelingCommand(c4d.MCOMMAND_MAKEEDITABLE, list = [obj], mode = c4d.MODIFY_ALL, bc=bc, doc = doc) doc.InsertObject(convert[0]) c4d.EventAdd() if __name__=='__main__': main()
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 09:41, xxxxxxxx wrote:
Hi ScottA thank you for your reply it works great on a preprepare hair object in cinama but when i generate the hair object in python its not working and use the script below is the one im trying to get it to work with any ideals cheers bud.
def main() :
c4d.CallCommand(1018401) # Add Hair
Cube= doc.SearchObject("Cube")
obj = doc.SearchObject("Hair")
obj[c4d.HAIRSTYLE_LINK]= Cube
obj[c4d.HAIRSTYLE_INSTANCE_LINK]= Cube #Puts the INSTANCE into the hair's link field
obj()[c4d.HAIRSTYLE_GENERATE]=6
obj[c4d.HAIRSTYLE_GENERATE] = c4d.HAIRSTYLE_GENERATE_POLYGONS_INSTANCE
bc = c4d.BaseContainer()
c4d.EventAdd()
convert = utils.SendModelingCommand(c4d.MCOMMAND_MAKEEDITABLE,
list = [obj],
mode = c4d.MODIFY_ALL,
bc=bc, doc = doc)
doc.InsertObject(convert[0])
c4d.EventAdd()
if __name__=='__main__':
main()Cheers Ray.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 12:17, xxxxxxxx wrote:
Give this a try:
import c4d import sys, time from c4d import utils def main() : obj = doc.GetActiveObject() #The object you want to add the hair on c4d.CallCommand(1018401) #Adds the hair object and automatically links it to the active object hair = doc.SearchObject("Hair") #Grab the new hair object and give it a variable assignment so we can use it for stuff Cube= doc.SearchObject("Cube") #Grab the instance object we'll add to the hair's instance field later on #Change the "Generate" option to "instance" mode hair[c4d.HAIRSTYLE_GENERATE]=c4d.HAIRSTYLE_GENERATE_POLYGONS_INSTANCE #Now that the mode is correct...We can put the instance object into the link field hair[c4d.HAIRSTYLE_INSTANCE_LINK]= Cube c4d.EventAdd() #Force C4D to update the changes c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) #IMPORTANT!! Redraw all the views before proceeding further!!! time.sleep(2) #Give the sysytem time to catch up convert = utils.SendModelingCommand(c4d.MCOMMAND_MAKEEDITABLE, list = [hair], mode = c4d.MODIFY_ALL, bc=c4d.BaseContainer(), doc = doc) doc.InsertObject(convert[0]) c4d.EventAdd() if __name__=='__main__': main()
Generating hairs can take a long time. Depending on how many you're generating.
It might be bad practice to do this kind of thing from a script. So be careful with how many hairs you generate.Using Sleep() & DrawViews() like I did in this case lets C4D sort of catch it's breath for a second. And get caught with all of the changes that happened.
But it's a terrible hack...Not something I'd want to use a lot.
There might be a better(safer) way to make the script pause and catch up.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 12:44, xxxxxxxx wrote:
Thanks ScottA i would of never got that 1 your a life saver.
Cheers Ray. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 13:00, xxxxxxxx wrote:
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 13:05, xxxxxxxx wrote:
Hi worked dream juast at add 1 line of script to get it to run final script for any 1 how needs this
import c4d
import sys, time
from c4d import utils
def main() :
obj = doc.GetActiveObject() #The object you want to add the hair on
c4d.CallCommand(1018401) #Adds the hair object and automatically links it to the active object
hair = doc.SearchObject("Hair") #Grab the new hair object and give it a variable assignment so we can use it for stuff
Cube= doc.SearchObject("Cube") #Grab the instance object we'll add to the hair's instance field later on
#Change the "Generate" option to "instance" mode
hair[c4d.HAIRSTYLE_GENERATE]=c4d.HAIRSTYLE_GENERATE_POLYGONS_INSTANCE
#Now that the mode is correct...We can put the instance object into the link field
hair[c4d.HAIRSTYLE_LINK]= Cube
hair[c4d.HAIRSTYLE_INSTANCE_LINK]= Cube
c4d.EventAdd() #Force C4D to update the changes
c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW) #IMPORTANT!! Redraw all the views before proceeding further!!!
time.sleep(2) #Give the sysytem time to catch up
convert = utils.SendModelingCommand(c4d.MCOMMAND_MAKEEDITABLE,
list = [hair], mode = c4d.MODIFY_ALL,
bc=c4d.BaseContainer(), doc = doc)
doc.InsertObject(convert[0])
c4d.EventAdd()
if __name__=='__main__':
main()
The line of script add was
hair[c4d.HAIRSTYLE_LINK]= Cube
Once again ScottA great job.
Cheers Ray -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/05/2012 at 13:43, xxxxxxxx wrote:
You're welcome.
Just don't use it in anything you sell, or make for other people.
Not because of credit issues.. But because using Sleep() like that is probably a bad idea. And can easily lead to crashes.-ScottA