I would like to add points to a spline, spreading them evenly, without changing the shape of this spline.
I can do a python script, but is there a simple way to make this change ?
Posts made by Kantronin
I am using a datafield of type AddEditNumberArrows, and I want to have increase or decresase of 0.1
I defined it like this:
And I initialized it in the following way:
Currently, the values of increments or decrementations are egal to 1.
How to have 0.1 ?
RE: Transform coordinates of a polygon's points
Indeed, it is necessary to use two matrices
For an object named polygonName, we will have:
Matrix = polygonName.GetMg () inverseMatrix = ~ Matrix
Matrix converts local coordinates to global coordinates.
After finishing working in global coordinates, we return to local coordinates with inverseMatrix
We can thus modify the polygon with the new local coordinates.
These two matrices allow to work with the points, which is very convenient.
This subject is very well explained here:
Transform coordinates of a polygon's points
C4D has a complex coordinate system.
- world coordinates
- local coordinates
- object coordinates (we can see them in the outliner, for selected object)
For the problem I am asking, I don't wish to have a general theory answer, concerning the coordinates system, but to obtain precise answers.
Here is my problem:
For a polygon, we can get easily the array of points and then display the position of this points as follows:
tabPoint = polygon.GetAllPoints() for point in tabPoint: print point
But I would like to knowhow to display the position of points of this polygon in the World coordinates ?
Then if I change the World coordinates of some points, how to convert this coordinates for modify the array of points for this polygon ?
I indicate below in what order are these two questions:
- Step 1: access the array of points for a polygon and therefore access the coordinates (very easy)
- Step 2: Conversion of these coordinates to world coordinates (first question)
- Step 3: change the position of some points of this polygon in the world coordinates (very easy)
- Step 4: Conversion of these world coordinates to the format of the array of points for this polygon (second question)
- Step 5: Modification of this polygon with the new array of point (very easy)
You may want to know why I am asking these questions, here is the reason.
I have two polygons that represent cliffs, but they do not coincide very well.
I have to bring closer the dots of theses cliffs to obtain a perfect join.
I'm doing this work to make a canyon that I started in opensim (see link below)
my cliffs before the junction of points
My points alignment algorithm works well, but I'm stumbling on that damned C4D coordinate system !
RE: Objects created in real time
It was indeed the modal window that prevented the real-time display of objects.
By putting the code below, the display of objects is immediate.
def Execute(self, doc):
self.dlg = MyDialog()
self.dlg.Open(c4d.DLG_TYPE_ASYNC, -1, -1, 400, 200)
However, the plugin window opens to the left of my screen and to move it to the center of the screen, I must first enlarge it.
I find that a little strange !
But it can be considered that my problem is solved.
Thank you for your answers
Objects created in real time
I an converting all my C.O.F.F.E.E scripts to python.
But I have a problem with python at the real-time display of the objects I create.
I synthesized this problem in the simplified script below.
If I press on the button <Creation null polygon> the polygon will only show on the screen when I close the plugin window.
How to make the polygon appear on the screen without being obliged to close the plugin window ?
import c4d from c4d import gui, documents button_1 = 1000 class MyDialog(c4d.gui.GeDialog): def CreateLayout(self): self.SetTitle("Creation polygon") self.AddButton(button_1, c4d.BFH_LEFT, 300, 24, "Creation null polygon") self.GroupEnd() return True def Command(self, cid, msg): if cid == button_1: polygon = c4d.BaseObject(c4d.Opolygon) doc = c4d.documents.GetActiveDocument() doc.InsertObject(polygon) c4d.EventAdd() return True class MyCommandData(c4d.plugins.CommandData): def Execute(self, doc): dlg = MyDialog() dlg.Open(c4d.DLG_TYPE_MODAL, -1, -1, 400, 200) dlg.InitValues(self) return True if __name__ == "__main__": c4d.plugins.RegisterCommandPlugin(id=10000015, str="Creation polygon", info=0, icon=c4d.bitmaps.BaseBitmap(), help="", dat=MyCommandData())
How to print in the console ?
With a simple script python, we can use 'print' to put a message in the console
But, with a python plugin this command don't work
I show my code here:
def Command(self, id, msg): if id == btnID: print 'Hello World!' #silently fails (no message in the console) print('Hello World!') #silently fails (no message in the console) gui.MessageDialog('Hello World!') #opens a dialog box and displays the message
Thank you for your observations