Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Python: Make Object Editable

Author
Message
  Topic Search Topic Search
Donovan Keith View Drop Down
Member
Member


Joined: 2002 Oct 30
Location: United States
Online Status: Offline
Posts: 199
Direct Link To This Post Topic: Python: Make Object Editable
    Posted: 2010 Oct 06 at 4:24pm

User Information:

Cinema 4D Version:   12.021 
Platform:      
Language(s):       PYTHON  ; 

---------

Background:
I'm trying to create a Python Generator object that will take a parametric spline object as an input and then spit out a standard spline with a B-Spline interpolation (specifically so I can round some of the harsh corners from a Turtle Mode MoSpline).

My question:
What is the equivalent of the "Make Object Editable" command in Python?


import c4d
#B-Spliner: Converts all child spline objects into a single spline of type B

def makeEditable(obj):
    return obj.GetVirtualObjects() #This command doesn't exist, what should I use instead?

def splineToBSpline(spline_obj):
    return spline_obj

def main():
    return splineToBSpline(makeEditable(op.GetDown()))


Edited by Donovan Keith - 2010 Oct 06 at 4:26pm
Back to Top
Donovan Keith View Drop Down
Member
Member


Joined: 2002 Oct 30
Location: United States
Online Status: Offline
Posts: 199
Direct Link To This Post Posted: 2011 Sep 28 at 1:16pm
This seems to work:

def MakeEditable(op):
    if debug: print "MakeEditable()"
    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]
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2011 Sep 29 at 9:54am
You could also use BaseObject.GetCache().
Back to Top
ripclaw View Drop Down
Member
Member
Avatar

Joined: 2010 Aug 05
Location: Berlin
Online Status: Offline
Posts: 73
Direct Link To This Post Posted: 2011 Sep 30 at 6:56am
c4d.CallCommand(12236) makes the currently selected object editable as well.
Back to Top
avd007 View Drop Down
Member
Member


Joined: 2010 Dec 31
Online Status: Offline
Posts: 134
Direct Link To This Post Posted: 2011 Oct 01 at 11:39am
Originally posted by nux95

You could also use BaseObject.GetCache().

THIS!!! so helpful, returns a polygon representation of almost any object... including cloners!
Back to Top
Matthias Bober View Drop Down
Forum Moderator
Forum Moderator


Joined: 2006 Oct 16
Location: Germany
Online Status: Offline
Posts: 2204
Direct Link To This Post Posted: 2011 Oct 02 at 8:19am
Originally posted by avd007

Originally posted by nux95

You could also use BaseObject.GetCache().

THIS!!! so helpful, returns a polygon representation of almost any object... including cloners!


Please be very careful using this function. It's not always guaranteed that the caches are build. The only time this is guaranteed is during rendering. Always check if the returned cache is valid. Please check the docs of the other cache functions as well (GetDeformCache, CheckCache).

cheers,
Matthias

MAXON
developer support
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2575
Direct Link To This Post Posted: 2011 Oct 02 at 8:32am
@Matthias: GetCache() returns 'None' while rendering, here. Is this what it's supposed to be ?
(Btw, is it an error that this topic appears in Python AND SDK Help forum ?)


Edited by nux95 - 2011 Oct 02 at 8:35am
Back to Top
avd007 View Drop Down
Member
Member


Joined: 2010 Dec 31
Online Status: Offline
Posts: 134
Direct Link To This Post Posted: 2011 Oct 02 at 11:22pm
Originally posted by Matthias Bober

Originally posted by avd007

Originally posted by nux95

You could also use BaseObject.GetCache().

THIS!!! so helpful, returns a polygon representation of almost any object... including cloners!


Please be very careful using this function. It's not always guaranteed that the caches are build. The only time this is guaranteed is during rendering. Always check if the returned cache is valid. Please check the docs of the other cache functions as well (GetDeformCache, CheckCache).

cheers,
Matthias


i tend to find that simply checking what your object is before your get the cache can be useful too. if its not he specific object you are looking for... than no cache is built. generally speaking GetRad() can be useful as well, when you don't need all the polygons and just need to approximate the object's size.
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.