Python script "Proxify"

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2012
Lightbulb Python script "Proxify"

Hi,

another little Python script, written because I just needed it: Proxify. It converts objects (children of a selected object) to Cube primitives that precisely resemble the bounding box of the original objects. Applied materials are simplified (new materials that have only the average color and specular settings of the original material).

Quite handy, if you want to pass a file to your animator to give him an impression of the scene without the need for high poly geometry and if you need high editor performance.

http://www.c4d-jack.de/site/en/down...36-proxify.html

Viel Spaß damit,
Jack

Attached Images
File Type: jpg proxify.jpg (81.3 KB, 210 views)
 
  09 September 2012
Very cool! Thank you!

Any way to Un-proxify?
__________________
----end of line

Last edited by Navstar : 09 September 2012 at 02:34 AM.
 
  09 September 2012
Duuuuude, get out of my head

That's awesome, you just saved me a lot of scripting/coding.

Thanks!
-kvb
__________________
www.kvbarnum.com
LOBODESTROYO!!!
 
  09 September 2012
I have something similar, especially for CAD files with lots of Axels.

In my Script you have to select a highpoly axel, and execute the script. It will replace the axel with a cylinder object with 16 faces.

when a special ratio of diameter to length is found (DIN Mutter) it will replace it with 6 faces cilynder with no phong tag.

My script is not perfect, and not fnished, but I'll post it here as a resource for coding.

script file attached code below.

kind regards.
mogh

# www.janweigand.de
import c4d
from c4d import documents, gui

def create_phongtag(myobject=op, angle=22, anglelimit=1):
    phongangle = c4d.utils.Rad(angle)
    mytag = myobject.MakeTag(c4d.Tphong)
    mytag[c4d.PHONGTAG_PHONG_ANGLELIMIT] = anglelimit
    mytag[c4d.PHONGTAG_PHONG_ANGLE] = phongangle
    return 

def create_cilynder(radius=10, height=20, seg=16, axis=0, hsub=1, caps=1, capsub=1, fillet=0, filletsub=1, filletradius=0.5, slize=0, sclizefrom=0, slizeto=180, grid=0, gridwidth=0.1):
    myobject = c4d.BaseObject(c4d.Ocylinder)    #Allocate a new object
    myobject[c4d.PRIM_CYLINDER_RADIUS] = radius
    myobject[c4d.PRIM_CYLINDER_HEIGHT] = height
    myobject[c4d.PRIM_CYLINDER_HSUB] = hsub
    myobject[c4d.PRIM_CYLINDER_SEG] = seg
    myobject[c4d.PRIM_AXIS] = axis
    myobject[c4d.PRIM_CYLINDER_CAPS] = caps
    myobject[c4d.PRIM_CYLINDER_CSUB] = capsub
    myobject[c4d.PRIM_CYLINDER_FILLET] = fillet
    myobject[c4d.PRIM_CYLINDER_FSUB] = filletsub
    myobject[c4d.PRIM_CYLINDER_FILLETRADIUS] = filletradius
    myobject[c4d.PRIM_SLICE] = slize
    myobject[c4d.PRIM_SLICEFROM] = sclizefrom
    myobject[c4d.PRIM_SLICETO] = slizeto
    myobject[c4d.PRIM_REGULAR] = grid
    myobject[c4d.PRIM_REGULARWIDTH] = gridwidth
    doc.InsertObject(myobject)     #Insert the object into the documents object list
    return myobject
 
def main():
    c4d.CallCommand(1024314);
    doc.StartUndo()                             #Start the storing of undo commands and data
    activeobject = doc.GetActiveObject()
    if activeobject==None: return
    #lowpoly_layer = doc.SetLayerData(self)

    boundingbox = activeobject.GetRad()
    atuple = (boundingbox.x, boundingbox.y, boundingbox.z)
    alist = list(atuple)
    alist.sort()
    alist.reverse()
    print alist
    nutrate_m4 = round(7.0/3.2, 3) 				# M4  standard Nut DIN 934
    nutrate_m4flat = round(7.0/2.2, 3) 			# M4  standard Nut DIN 934 flat
    nutrate_m5 = round(8.0/4.0, 3) 				# M5  standard Nut DIN 934
    nutrate_m5flat = round(8.0/2.7, 3) 			# M5  standard Nut DIN 934 flat
    nutrate_m6 = round(10.0/5.0, 3) 			# M6  standard Nut DIN 934
    nutrate_m6flat = round(10.0/3.2, 3) 		# M6  standard Nut DIN 934 flat
    nutrate_m8 = round(13.0/6.5, 3) 			# M8  standard Nut DIN 934
    nutrate_m8flat = round(13.0/4.0, 3) 		# M8  standard Nut DIN 934 flat
    nutrate_m10 = round(17.0/8.0, 3) 			# M10 standard Nut DIN 934
    nutrate_m10flat = round(17.0/5.0, 3) 		# M10 standard Nut DIN 934 flat
    nutrate_m10_new = round(16.0/8.0, 3) 		# M10 standard Nut DIN ??? NEW
    nutrate_m10flat_new = round(16.0/5.0, 3) 	# M10 standard Nut DIN ??? flat NEW
    nutrate_m12 = round(19.0/10.0, 3) 			# M12 standard Nut DIN 934
    nutrate_m12flat = round(19.0/6.0, 3) 		# M12 standard Nut DIN 934 flat
    nutrate_m16 = round(24.0/13.0, 3) 			# M16 standard Nut DIN 934
    nutrate_m16flat = round(24.0/8.0, 3) 		# M16 standard Nut DIN 934 flat 
    nutrate_m20 = round(30.0/16.0, 3) 			# M20 standard Nut DIN 934
    nutrate_m20flat = round(30.0/10.0, 3) 		# M20 standard Nut DIN 934 flat
    nutrate_m24 = round(36.0/19.0, 3) 			# M24 standard Nut DIN 934
    nutrate_m24flat = round(36.0/12.0, 3) 		# M24 standard Nut DIN 934 flat
    nutrate_x1 = round(8.5/4.0, 3)				# sondermaߠ?

    nutlist = (nutrate_m4, nutrate_m4flat, nutrate_m5, nutrate_m5flat, nutrate_m6, nutrate_m6flat, nutrate_m8, nutrate_m8flat, nutrate_m10, nutrate_m10flat, nutrate_m10_new, nutrate_m10flat_new, nutrate_m12, nutrate_m12flat, nutrate_m16, nutrate_m16flat, nutrate_m20, nutrate_m20flat, nutrate_m24, nutrate_m24flat, nutrate_x1)
    print nutlist
    ratio = round(alist[1]/alist[2], 3)
    print ratio
	
    if ratio in nutlist:
 
        height = alist[2] * 2
        radius = alist[0]        
        seg=6
        if boundingbox.x < boundingbox.y and boundingbox.x < boundingbox.z: 
            axis = 0
        elif boundingbox.y < boundingbox.x and boundingbox.y < boundingbox.z:
            axis = 2
        elif boundingbox.z < boundingbox.x and boundingbox.z < boundingbox.y:
            axis = 4
		
    elif boundingbox.x != boundingbox.y and round(boundingbox.y) == round(boundingbox.z):
        height = boundingbox.x * 2
        radius = (boundingbox.y + boundingbox.z) / 2
        axis = 0
        seg=16

    elif boundingbox.y != boundingbox.x and round(boundingbox.x) == round(boundingbox.z):
        height = boundingbox.y * 2
        radius = (boundingbox.x + boundingbox.z) / 2
        axis = 2
        seg=16

    elif boundingbox.z != boundingbox.x and round(boundingbox.x) == round(boundingbox.y):
        height = boundingbox.z * 2
        radius = (boundingbox.x + boundingbox.y) / 2
        axis = 4
        seg=16

    else:
        # gui.MessageDialog('Keine Mutter oder Zylinder erkannt!')
        print 'Keine Mutter oder Zylinder erkannt!'
        return

    myobject = create_cilynder(radius, height, seg, axis)
    activeobject.CopyMatrixTo(myobject)
    #name=activeobject.GetName()
    myobject.SetName(activeobject.GetName() + ' lowpoly') #set and apend the objectname
    create_phongtag(myobject, 44, 1)            #call phontag funcction
    doc.AddUndo(c4d.UNDOTYPE_NEW, myobject)     #Add an undo notification for the new object
    doc.AddUndo(c4d.UNDOTYPE_DELETE, activeobject) #Add an undo notification for the new object
    activeobject.Remove()                       #delete the active object
    doc.EndUndo()                               #End the storing of undo data
    c4d.EventAdd()                              #Refresh the managers to show the new object

main()
Attached Files
File Type: zip Replace with low poly.zip (1.7 KB, 11 views)
__________________
R19 Visualize - Flickr Album - Website
 
  09 September 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:03 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.