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).
Hi:
@PATPAT First of all, the point movement algorithm of attitude deformation label is not complicated.
I've seen in some tutorials that you can add some data to a port with unconventional operations, but I forgot . So, I use Python nodes.
The data control label object weight value for the input port, so you need to add a user data of type link to the Python node.
Python is a dynamic language, and data types cannot be determined before compilation. There is no conditional right or wrong judgment in my code, so please add them by yourself.
import c4d def main(): obj = op[c4d.ID_USERDATA,1] Tags = obj.GetTags() Pose = [tag for tag in Tags if tag.GetRealType() == 1024237] #[4000,1101] is the ID of the strength value. Pose[0][4000,1101] = Input1 global Output1 Output1 = Pose[0][4000,1101]
After a trial run, the script was tested successfully. By setting the name suffix of Python Tag, the problem of repeated running of Tag can be solved.
Taking c4d.DIRTYFLAGS_SELECT as an example, if the point, line, and surface selections change, it will execute, otherwise it won't.
The Python script code is as follows:
import c4d #e-mail: [email protected] def main(): Name = op.GetName() Objects = op.GetObject() Changed = Objects.GetDirty(c4d.DIRTYFLAGS_SELECT) Text = ["xit" + str(Changed)[-1]] if str(Name).count(Text[0][:-1]) != 0 : if str(Name).find(Text[0][:-1]) != str(Name).rfind(Text[0][:-1]) : if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] : if str(Name).find(Text[0][:-1]) <= 0: #Do not execute, exit the program. print ("Does not perform.") op.SetName(str(Text[0])) return else: #Do not execute, exit the program. op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Does not perform.") return else: if str(Name).find(Text[0][:-1]) <= 0: op.SetName(str(Text[0])) print ("Perform.") else: op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Perform.") else: if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] : #Do not execute, exit the program. print ("Does not perform.") return else: op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Perform.") else: print ("Perform.") op.SetName(str(Name) + str(Text[0])) print ("pass") #The next thing to execute.
HI:
I recently doing point cloud reconstruction, and it's really not a difficult problem. So the first thing you have to do is figure out 2 points and the center of the circle, so there are 3 points.Then figure out the length of each side of the triangle surrounded by 3 points, and finally figure out the Angle between 2 points and the center of the circle.You plug in the arc length formula and you get the arc length between 2 points.
@kbar Thank you very much for your great work, because C++ development documentation has long lacked user education, and .XDL64 files cannot be generated smoothly even for novices who have the source files.You are really great to replace the SDK-team to complete the user education.
Before you posted the video, many people posted C++ development videos for C4D, but after version R19, the API interface parameters changed, and these videos lost their user education significance.Thank you for your contribution to making more people learn how to generate .XDL64 files. This is the first and most important first step.
@ferdinand Generating the .XDL64 file is the most important first step, but in the C++ development documentation, the Project Tool chapter is very professional and prevents novices from properly generating the .XDL64 file.
Suggest additional development steps, such as 1,2,3,..... Such as:
1: Download the Project Tool. 2: Create a new .TXT file and write it to ......\cinema4d_r23_project_tool_314356_win-macos\kernel_app_64bit.exe g_updateproject=...... 3: .TXT file format changed to.bat. 4: ... 5: ... ......
edit: This topic has been forked from C++ Plugin Development Tutorials [Ferdinand]
Hello @ferdinand :
In this transition period , can you make a small change and write a detailed C++ plug-in development process in the forum ? Collect the development details of the scattered generated compiled files into a post and place it at the top of the forum.
Do you want to make a complete copy of another polygon object from scratch using Python tags?Including n-gon edges.
You hide edges incorrectly, it's still not an n-gon edge, it's just an edge selection.I have the full Python tag code, which is fast, but I won't post it here.However, this Python tag only runs in R23 and up.Since Python cannot directly create polygons with n-gon edges, it can only be done with the Model Elimination command in versions R23 and above.
Your Python code isn't optimal, so it's not fast.The fastest way to do this is to use C++, which can create polygons with n-gon edges directly and at tens of times the speed of Python tags.Also, Python tags create n-gon polygons that don't have the same edge indexes as the n-gon polygons that copy objects, which is one of Python's flaws.
You can generate multiple cache items in the Python generator at the same time, such as polygon objects, material labels, standard material balls, and vector color labels, but you cannot add vector color labels to material balls. Base_Objects and Base_tag can be added to cached documents at this stage, while materials cannot be added to cached documents at this stage.The vector color tag exists in the cached document, and the material exists in the active document. The material cannot receive the vector color tag in the cached document, so this is not possible.
Even though it might someday be possible to add a polygon object, a material label, a standard material ball, and a vector color label to a cached document, the renderer can only receive one document for rendering, so that's not possible.
Please use Python tags, entities to generate various objects, this is to achieve the desired effect.If done through the Python generator, the final result simply returns None, remembering to insert various objects into the current document.
Your problem is that the material ball is stored on the hard disk, while the polygon object generated by the Python generator is stored on the memory strip (cache).Only objects from the hard disk can be added to the cache. Cache objects must be instantiated (collapsed) to be added to the hard disk. To display shading, a material ball is required, but the vector color tag in the cache cannot be added to the material ball in the hard disk. There are two solutions:
I want to get the point weights of non-Python Field objects . I looked carefully at the Python Effectors code that came with it and knew that FieldOutput was an instance . Suppose you create a new Plain effect and create a cube field . Is there a way to get the weight of the cube field points?
FieldOutput
The fieldOutput.getValue (Index) function cannot get the point weights of other Field objects. So , is there any way to get the weights?That seems difficult to achieve.
fieldOutput.getValue (Index)
I think it might be faster to try to import the point location directly as an external library (.py). At the same time, C4D supports importing Illustrator files, and SVG can be processed in Illustrator before importing C4D. Here is a simple SplineObject code.
import c4d def main(): #The location of the point. Points = [c4d.Vector(0, 0, 0),c4d.Vector(0, 0, 2),c4d.Vector(0, 4, 4)] #Initializes the spline object. Spline = c4d.SplineObject(len(Points), c4d.SPLINETYPE_LINEAR ) #Change the number of spline object segments, the number of points. Spline.ResizeObject(len(Points), 3) #Set the locations of all the points of the spline object. Spline.SetAllPoints(Points) #Set properties of the segment. Spline.SetSegment(0, len(Points), True) #Close the spline object. Spline[c4d.SPLINEOBJECT_CLOSED] = 1 #Inserts the spline object into the current document. doc.InsertObject(Spline) #Update current document, routine code. c4d.EventAdd() if __name__=='__main__': main()
@delizade
I don't think it's necessary to import external libraries, because such simple code can be used directly.I have a suggestion that you should add data in Python tag, not in the object where the Python tag are located. As for the Python tag running repeatedly, it is because your code has no conditional comparisons.Here is the Python tag code, based on the file you provided, that will only run when the frame changes.
import c4d def myFunction(getObj): obj=getObj.GetObject() var1=obj[c4d.ID_USERDATA,1] print (var1) print ("myFunction: "+str(var1)) #c4d.EventAdd() def main(): frame = doc.GetTime().GetFrame(doc.GetFps()) obj = op.GetObject() var1 = obj[c4d.ID_USERDATA,1] if frame * 0.01 != var1: print (var1) print ("myFunction: "+str(var1)) obj[c4d.ID_USERDATA,1] = frame * 0.01 c4d.EventAdd()
@peXel
Sorry, I was negligent. The reset code of rotation and zoom is as follows.
import c4d #from c4d import Vector as V def main(): if op.CheckType(c4d.Opolygon): #if op is None or not op.CheckType(c4d.Opoint): #return False ObjMatrix = c4d.Matrix() #op.GetMg() #ObjPoints = op.GetAllPoints() #Pcount = op.GetPointCount() doc.StartUndo() doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) #op.SetAbsRot(V(0)) #op.SetAbsPos(V(0)) op.Message(c4d.MSG_UPDATE) #NewMatrix = op.GetMg() point = [ op.GetAllPoints()[i] * op.GetMg() * ~ObjMatrix for i in range(op.GetPointCount()) ] op.SetMg(ObjMatrix) op.SetAllPoints(point) op.Message(c4d.MSG_UPDATE) c4d.EventAdd() doc.EndUndo() else: doc.StartUndo() doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) op.SetMg(c4d.Matrix()) op.Message(c4d.MSG_UPDATE) c4d.EventAdd() doc.EndUndo() if __name__=='__main__': main()