Calling Bevel tool and setting parametrs
Just when I thought I might be getting the hang of python in C4D I ran into a challenge of trying to bevel an edge selection. I've been able to piece together most of what I think I need but I've run into two problems. The first being that I can't set the offset of the tool and second I must be missing some sort of command to have the polygons show up after the resulting bevel takes place. I've been scouring the forums and trying a bunch of things for the last few hours and I've come to the point where I have to throw in the towel and seek professional help.
Any and all help is appreciated.
Here's what I have so far -
tags = op.GetTags() for tag in tags: if tag.GetType()==5701: #edge selection doc.SetMode(c4d.Medges) selection = tag.GetBaseSelect() edgeSelected = op.GetEdgeS() selection.CopyTo(edgeSelected) c4d.CallCommand(431000015,431000015) # xll bevel tool tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL) bcBevel = doc.GetActiveToolData() bcBevel.SetData(c4d.MDATA_BEVEL_OFFSET_MODE, 0) bcBevel.SetData(c4d.MDATA_BEVEL_RADIUS, 1) bcBevel.SetData(c4d.MDATA_BEVEL_SUB, 2) bcBevel.SetData(c4d.MDATA_BEVEL_DEPTH, 1) bcBevel.SetData(c4d.MDATA_BEVEL_SELECTION_PHONG_BREAK, False) c4d.CallButton(tool, c4d.MDATA_APPLY) op.Message(c4d.MSG_UPDATE) c4d.EventAdd()
Hi @del thanks for reaching us,
As you figured the new bevel tool is c4d.ID_XBEVELTOOL (431000015) (I will update the python documentation) but in order to make it work the recommended way is to use SendModelingCommand like so
import c4d doc.StartUndo() # Settings settings = c4d.BaseContainer() settings[c4d.MDATA_BEVEL_MASTER_MODE] = c4d.MDATA_BEVEL_MASTER_MODE_SOLID settings[c4d.MDATA_BEVEL_RADIUS] = 5 settings[c4d.MDATA_BEVEL_SELECTION_PHONG_BREAK] = False doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) res = c4d.utils.SendModelingCommand(command = c4d.ID_XBEVELTOOL, list = [op], mode = c4d.MODELINGCOMMANDMODE_EDGESELECTION, bc = settings, doc = doc) doc.EndUndo() c4d.EventAdd()
You can find a list of all symbols in the cpp documentation of xbeveltool.h.
Hi and thanks for the help.
I tried the script but I don't get any results. No error message and no change to the model. Please keep in mind that I'm in R19 if that makes a difference. I tried it in R20 and it creates a bevel. Not the bevel I expected but it was at least promising that it did something.
Here is what I have based on your info.
import c4d from c4d import utils def main(): bcBevel = c4d.BaseContainer() bcBevel[c4d.MDATA_BEVEL_MASTER_MODE] = c4d.MDATA_BEVEL_MASTER_MODE_CHAMFER bcBevel[c4d.MDATA_BEVEL_OFFSET_MODE] = c4d.MDATA_BEVEL_OFFSET_MODE_FIXED bcBevel[c4d.MDATA_BEVEL_RADIUS] = 1 bcBevel[c4d.MDATA_BEVEL_SUB] = 2 bcBevel[c4d.MDATA_BEVEL_DEPTH] = 1 bcBevel[c4d.MDATA_BEVEL_SELECTION_PHONG_BREAK] = False tags = op.GetTags() for tag in tags: if tag.GetType()==5701: doc.StartUndo() doc.SetMode(c4d.Medges) selection = tag.GetBaseSelect() edgeSelected = op.GetEdgeS() selection.CopyTo(edgeSelected) doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) res = c4d.utils.SendModelingCommand( c4d.ID_XBEVELTOOL, [op], c4d.MODELINGCOMMANDMODE_EDGESELECTION, bcBevel, doc) doc.EndUndo() c4d.EventAdd() if __name__=='__main__': main()
C4D might have been 'messed up' based on my prior attempts. I've restarted it and may be making progress.
Here in R19 it's working nicely. Let me know if you are able to reproduce the issue.
Restarting c4d fixed it! Now I just have to get the hidden polys produced by the bevel to appear. I'm pretty sure I need a message update or something like that as they appear once I move the model.
Thanks for your help.
Does anybody know what format I'm supposed to use to send a number to the Bevel tool for the radius? I'm currently only able to get it to work with whole numbers like 1 or 2. I'd like to set it to .5.
I've tried float(.5) and int(.5) but both end up giving me no bevel. I can't find any documentation for this.
found it!!! I had to float('0.5')
settings[c4d.MDATA_BEVEL_RADIUS] = 0.5
Works fine here.