THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/04/2012 at 03:49, xxxxxxxx wrote:
For some reason this parameter will not initialise
I want it to initialise to ZY - not the default XY
in the build - the same approach sets the parameter correctly
see below under ...
1 of 2 ############ just testing stuff.
2 of 2 ############ just testing stuff.
import c4d, sys, os
from c4d import plugins, utils as u, bitmaps, gui,documents, Vector as v
PLUGIN_ID = 1028416 #unique plugin id from plugincafe.com
class JSplineObject(plugins.ObjectData) :
########################## Init interface and values
def Init(self, op) :
op.SetName("J Spline Creator") #op is the generator object
doc = documents.GetActiveDocument
self.InitAttr(op, float, [c4d.P1]) #Init the values you defined in your res file
op[c4d.P1] = 40.0 #Set a default value for point1
self.InitAttr(op, float, [c4d.P2])
op[c4d.P2] = 20.0
self.InitAttr(op, float, [c4d.P3])
op[c4d.P3] = 10.0
self.InitAttr(op, float, [c4d.CHAMFER])
op[c4d.CHAMFER]= 1.0
self.InitAttr(op, bool, [c4d.CHAMFER_FLAT])
op[c4d.CHAMFER_FLAT] = False
self.InitAttr(op, bool, [c4d.OUTLINE])
op[c4d.OUTLINE] = True
self.InitAttr(op, float, [c4d.OUTLINE_OFFSET])
op[c4d.OUTLINE_OFFSET] = 5.0
self.InitAttr(op, bool, [c4d.CHAMFER_BASE])
op[c4d.CHAMFER_BASE] = False
self.InitAttr(op, bool, [c4d.CHAMFER_TAIL])
op[c4d.CHAMFER_TAIL] = False
########################### 1 of 2 ############ just testing stuff...
op[c4d.PRIM_PLANE] = c4d.PRIM_PLANE_ZY #### NEITHER THIS OR 1 Works??
op[c4d.PRIM_REVERSE] = 1 #True
op[c4d.SPLINEOBJECT_INTERPOLATION] = c4d.SPLINEOBJECT_INTERPOLATION_SUBDIV
op[c4d.SPLINEOBJECT_SUB] = 8 # long?
op[c4d.SPLINEOBJECT_ANGLE] = u.Rad(4) # float?
op[c4d.SPLINEOBJECT_MAXIMUMLENGTH] = 5 # float?
########################### 1 of 2 ############ test to here
return True
###################END#### Init interface and values
########################## Build
def Build(self,op) :
p1 = op[c4d.P1]
p2 = op[c4d.P2]
p3 = op[c4d.P3]
chamfer_amount = op[c4d.CHAMFER]
chamfer_flat_switch = op[c4d.CHAMFER_FLAT]
outline_switch = op[c4d.OUTLINE]
outline_offset = op[c4d.OUTLINE_OFFSET]
chamfer_base_switch = op[c4d.CHAMFER_BASE]
chamfer_tail_switch = op[c4d.CHAMFER_TAIL]
############# a few limits
if p2 < chamfer_amount :
p2 = chamfer_amount
op[c4d.P2] = p2
############# a few limits - dont let the tail be bigger than J Height
if p3 > p1 :
p3 = p1
op[c4d.P3] = p3
if p3 < -p1 :
p3 = -p1+ 0.1
op[c4d.P3] = p3
############# if both swiches off - ignore amount in AM and zero
if (chamfer_base_switch == False) and (chamfer_tail_switch == False) :
chamfer_amount = 0
jspline = c4d.SplineObject(4,c4d.SPLINETYPE_BEZIER)
jspline.SetPoint( 0, v(0.0, p1, 0.0))
jspline.SetPoint( 1, v(0.0, 0.0, 0.0))
jspline.SetPoint( 2, v(-p2, 0.0, 0.0))
jspline.SetPoint( 3, v(-p2, p3, 0.0))
jspline[c4d.SPLINEOBJECT_CLOSED] = False
sel = jspline.GetPointS()
sel.DeselectAll()
############# select points depending on AM checkbox
if chamfer_base_switch == True:
sel.Select(1)
if chamfer_tail_switch == True:
sel.Select(2)
############# chamfer the spline
bc = c4d.BaseContainer()
bc.SetData(c4d.MDATA_SPLINE_CHAMFERFLAT, chamfer_flat_switch )
bc.SetData(c4d.MDATA_SPLINE_CHAMFERRADIUS, chamfer_amount)
result = u.SendModelingCommand(c4d.ID_MODELING_SPLINE_CHAMFER_TOOL, [jspline],c4d.MODELINGCOMMANDMODE_POINTSELECTION, bc)
############# outline the spline
if outline_switch == True:
bc.SetData(c4d.MDATA_SPLINE_OUTLINE, outline_offset)
u.SendModelingCommand(c4d.MCOMMAND_SPLINE_CREATEOUTLINE,[jspline],c4d.MODELINGCOMMANDMODE_ALL,bc)
########################### 2 of 2 ############ test testing stuff...
########following same logic as above but prim_plane actually works
plane = op[c4d.PRIM_PLANE]
reverse = op[c4d.PRIM_REVERSE]
interp = op[c4d.SPLINEOBJECT_INTERPOLATION]
subd = op[c4d.SPLINEOBJECT_SUB]
ang = op[c4d.SPLINEOBJECT_ANGLE]
maxlen = op[c4d.SPLINEOBJECT_MAXIMUMLENGTH]
#### do some processing from included res Osplineprimitive;
#### in this case just print to console to check
print 'PLANE: ', plane
print 'REVERSE: ', reverse
print 'INTERP: ',interp
print 'SUBDIV: ', subd
print 'ANGLE: ', ang
print 'MAXLENGTH: ', maxlen
print ' '
############# just testing - put the values back????
op[c4d.PRIM_PLANE] = plane ##### essentially the same thing as the init WORKS?
op[c4d.SPLINEOBJECT_INTERPOLATION] = interp
op[c4d.PRIM_REVERSE] = reverse
op[c4d.SPLINEOBJECT_SUB] = subd
op[c4d.SPLINEOBJECT_ANGLE] = ang
op[c4d.SPLINEOBJECT_MAXIMUMLENGTH] = maxlen
########################### 2 of 2 ############ test to here
return jspline.GetClone()
############# Return the built spline
############# Go and return the built spline
def GetContour(self, op, doc, lod, bt) :
return self.Build(op)
if __name__ == "__main__":
dir, file = os.path.split(__file__)
icon = bitmaps.BaseBitmap()
icon.InitWith(os.path.join(dir, "res", "icon.png"))
JSplineCreator = plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="JSplineObject",
g=JSplineObject,
description="JSplineObject", icon=icon,
info=c4d.OBJECT_GENERATOR | c4d.OBJECT_ISSPLINE)
if JSplineCreator:
print 'JSplineCreator Loaded'