Liste der Anhänge anzeigen (Anzahl: 2)
Adventstürchen Nummer... die nächste...
Ich mach mal weiter, falls sich sonst niemand vordrängt :-)
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
Nuggi gemodelt für ein sehr persönliches Projekt. Entstanden mit C4D, Octane und Sperma. :-)
Liste der Anhänge anzeigen (Anzahl: 2)
Moin, weiter gehts heute für die Logistiker unter euch:
Eine nicht allzu detaillierte Gitterboxpalette UIC Norm 435-3
[Only registered and activated users can see links. Click Here To Register...]
edges to splines buttonversion
tag,
ich versuche gerade, mich in python einzulernen - hier ein zwischenstand eines skripts, das eigentlich mal ein generator werden soll - aber dafür stell' ich mich zur zeit wohl zu ungeschickt an. dachte, eine button-version könnte ja irgendjemandem nützlich sein - vllt. gab's das aber schon zig-mal.
was es macht:
objektselektion (auch mehrere) wird (über current state to object) in spline umgewandelt, spline wird oben eingefügt. bei 1 objekt-auswahl entsteht 1 spline-objekt, bei 1 objekt-auswahl inkl. children entsteht ebenfalls 1 spline-objekt (das parent inkl. children beinhaltet). bei x ausgewählten objekten entstehen x splines etc.
zu beachten:
falls bei irgendwelchen betroffenen objekten renderinstances angeklickt sind, werden die durch das skript zu non-renderinstances gemacht. danach also wieder umschalten, falls gewünscht.
am praktischsten natürlich, wenn man sich 'nen button irgendwo hinzieht...
Code:
import c4d
from c4d import utils, gui, Vector, Matrix
""" edges to splines buttonversion"""
""" beware: instances (if any) are being changed to non-renderinstances (if applicable) and NOT turned back """
def csto(obj_sel):
# turn off render-instances
def check_inst(obj_sel):
if obj_sel()[c4d.INSTANCEOBJECT_RENDERINSTANCE] == True:
obj_sel()[c4d.INSTANCEOBJECT_RENDERINSTANCE] = False
# Scan obj hierarchy and select children
def selobj(obj_sel,next):
while obj_sel and obj_sel != next:
obj_sel.SetBit(c4d.BIT_ACTIVE)
check_inst(obj_sel)
selobj(obj_sel.GetDown(),next)
obj_sel = obj_sel.GetNext()
return True
# go through hierarchy of crst_obj and connect all to 1 object
def join_scope(csto_obj):
csto_obj_clone = csto_obj.GetClone()
doc.SetActiveObject(csto_obj_clone)
# Scan obj hierarchy and select children
def selchildren(csto_obj_clone,next):
while csto_obj_clone and csto_obj_clone != next:
csto_obj_clone.SetBit(c4d.BIT_ACTIVE)
selchildren(csto_obj_clone.GetDown(),next)
csto_obj_clone = csto_obj_clone.GetNext()
return True
# if while-loop returns True, join
if selchildren(csto_obj_clone, csto_obj_clone.GetNext()):
csto_obj_clone.DelBit(c4d.BIT_ACTIVE)
solo = utils.SendModelingCommand(command = c4d.MCOMMAND_JOIN, list = [csto_obj_clone])
csto_solo_clone = solo[0]
# return clone of joined csto_object to csto-scope
return csto_solo_clone
# if while-loop returns True, do csto
if selobj(obj_sel, obj_sel.GetNext()):
obj_sel.DelBit(c4d.BIT_ACTIVE)
# current state to object
csto_command = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [obj_sel])
csto_obj = csto_command[0]
# return whatever came out of join_scope to main
return join_scope(csto_obj)
def edges_to_spline(obj_sel, rv_csto):
# definition of corrections
def correct_axis(spline_obj_clone, mat_rix, local = True):
if local:
m_obj = spline_obj_clone.GetMl()
else:
m_obj = spline_obj_clone.GetMg()
m = ~mat_rix * m_obj
if obj_sel.GetUp():
m = ~mat_rix * obj_sel.GetUp().GetMg()
point_cnt = spline_obj_clone.GetPointCount()
points = spline_obj_clone.GetAllPoints()
for i in xrange(point_cnt) :
points[i] = m.Mul(points[i])
spline_obj_clone.SetAllPoints(points)
if local:
spline_obj_clone.SetMl(mat_rix)
else:
spline_obj_clone.SetMg(mat_rix)
# initialize neighbors
nachbarn = utils.Neighbor(rv_csto)
nachbarn.Init(rv_csto)
# Set Select edges from edges-selection
edges = c4d.BaseSelect(rv_csto)
edges.SelectAll(nachbarn.GetEdgeCount()-1)
edge_select_var = rv_csto.SetSelectedEdges(nachbarn, edges, c4d.EDGESELECTIONTYPE_SELECTION)
# selected edges to spline object
utils.SendModelingCommand(command = c4d.MCOMMAND_EDGE_TO_SPLINE, list = [rv_csto])
children = rv_csto.GetChildren()
spline_obj_clone = children[0].GetClone()
# correct messed up csto
v1, v2, v3 = Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)
source_mat = obj_sel.GetMg() # get op's mg
mat_rix = Matrix(source_mat, v1, v2, v3) # create new instance of matrix
correct_axis(spline_obj_clone, mat_rix)
# insert spline and name it accordingly
spline_obj_clone[c4d.ID_BASELIST_NAME] = str(obj_sel.GetName() + " - Spline")
doc.InsertObject(spline_obj_clone)
spline_obj_clone.Message(c4d.MSG_UPDATE)
def main():
# some stuff
#doc = c4d.documents.GetActiveDocument() # not allowd in main?
global obj_sel
# get selected objects
obj_sel_cont = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
if obj_sel_cont:
# itereate through selected objects
for cnt, i in enumerate(obj_sel_cont):
obj_sel = obj_sel_cont[cnt]
# current state of op to 1 object
rv_csto = csto(obj_sel)
# edges to spline
edges_to_spline(obj_sel, rv_csto)
else:
gui.MessageDialog("needs selected object(s) that need(s) to contain some kind of geometry")
if __name__ == '__main__':
main()
#c4d.EventAdd() # not allowd in main?
Liste der Anhänge anzeigen (Anzahl: 1)
[Only registered and activated users can see links. Click Here To Register...]
Ich könnte noch den Schoppen nachlegen, aber dann muss vorher sonst noch jemand was Spenden. mimimi
Was ist mit den Franzosen los? [Only registered and activated users can see links. Click Here To Register...]