Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello everyone. I have a question that I want to create object solid from spline. Can you show code C++ or Python ?. Thanks you very much.
Hi,
welcome to the forum. I am afraid this is not how things are working here. Your question is rather vague and also of such complexity that probably neither the SDK team nor forum members are willing to do the work for you. Some pointers.
Cheers zipit
Hello and welcome,
before posting, please make sure you are familiar with this forum's rules and procedures: How to Post Questions
What kind of plugin do you want to write? A simple script, a tool or a generator? Are you familiar of the basic concepts of Cinema 4D? Do you have any previous coding experience?
For simplicity's sake I will present some Python code in form of a Python Script. The concepts can be transferred to C++ as well.
A polyon object is created by creating an instance of the PolygonObject class. This instance can be modified and then inserted in to the document.
import c4d def main(): # create polygon object numberOfPoints = 4 numberOfPolygons = 1 polyObject = c4d.PolygonObject(numberOfPoints, numberOfPolygons) if polyObject is None: raise RuntimeError("Could not create PolygonObject.") # set points points = [] points.append(c4d.Vector(0,0,0)) points.append(c4d.Vector(0,0,100)) points.append(c4d.Vector(100,0,100)) points.append(c4d.Vector(100,0,0)) polyObject.SetAllPoints(points) # set polygons polygon = c4d.CPolygon(0,1,2,3) polyObject.SetPolygon(0, polygon) # insert object into document doc.InsertObject(polyObject, None, None) # update C4D c4d.EventAdd() if __name__=='__main__': main()
Similarly, a spline is represented as a SplineObject. You can use the SplineHelp class to access positions along the spline:
import c4d def main(): # access active object if op is None: raise RuntimeError("No object selected") # check if active object is a spline object if op.GetType() != c4d.Ospline: raise RuntimeError("Object is no spline object") # init SplineHelp splineHelp = c4d.utils.SplineHelp() res = splineHelp.InitSpline(op) if res == False: raise RuntimeError("Could not init SplineHelp.") # Sample positions along the spline for i in xrange(20): offset = i * .05 pos = splineHelp.GetPosition(offset, 0) print(pos) if __name__=='__main__': main()
With that information you can build your poylgons.
You find more complex examples how to create poylgon objects in various generator plugins:
best wishes, Sebastian
Thanks everyone.
The purpose of me is export model from revit to cinema 4d. I choose other way. Thanks you very much.