Selecting Different components but in Different modes
-
Thank you very much.
The "swizzling" can be achieved with the Axis Center:
using these settings.
BUT the code you posted is very valuable for me to evolve my spaghetti coding... copy from here, and paste thereThanks Again!
-
Full disclosure, I just realized that in "Axis Modification" Tool, when in Polygon mode, if you hover over an edge and click, it places the Axis there...
I guess most of what I was trying to do is already there..."The path to wisdom, is paved with errors..."
[just made that up...] Noseman -
Hi,
I was not aware that Cinema can do this and I thought that was what you were going for, given your statement '[..] and the modeling Z Axis to align to that edge [...]'. Also: Swizzling is just computer graphics slang for creating a new vector or matrix by shuffling the components of an existing vector or matrix.
Since I do not really understand what you are trying to do, I cannot really point you into the right direction. I can only point out that the 'matrix maths' that comes up with transforms in Computer Graphics is not all that scary. I made post here and recently here on the topic. Feel free to come back if you have any problems.
Cheers,
zipit -
hi,
@noseman said in Selecting Different components but in Different modes:
Full disclosure, I just realized that in "Axis Modification" Tool, when in Polygon mode, if you hover over an edge and click, it places the Axis there...
I guess most of what I was trying to do is already there...yes, the only thing that doesn't answer your question it that you want the Z axis to be align with the edge.
The "L" shortcut come really useful if you keep that shortcut pressed while clicking on the polygon/edge/point you want to move to your axis. Than when you release the shortcut, is disable that command.Don't be afraid of math, it's like cos, sin, tan, for some artist out there, it's really useful and not so complicated. (sometimes it's just function that you need to apply, not to understand like going from local to global and global to local)
Cheers,
Manuel -
Hi:
This is a very old post, but it's very helpful.
I have found the algorithm for the Z axis to be align with the edge, but the sample script from the post does not restore the modeling axis. Can you provide a method to restore the original default modeling axis?
-
hi,
To "save" the current modeling axis matrix, as you are (i think) using a script, you need to save the matrix inside the document's
BaseContainer
Of course you have to retrieve your own unique ID (the icon on the top of this page)import c4d from c4d import gui # this ID have to be unique myownID = 123456 # Main function def main(): if op is None: return if doc is None: raise ValueError("doc isn't initialized !!!") # retrieves the modeling axis mmt = op.GetModelingAxis(doc) # saves the modeling axis inside the document's BaseContainer' doc[myownID] = mmt # swaps the axis temp = mmt.v1 mmt.v1 = mmt.v3 mmt.v3 = temp * -1.0 # Sets the modeling axis op.SetModelingAxis(mmt) # Pushes an update event to Cinema 4D c4d.EventAdd() # Execute main() if __name__=='__main__': main()
to restore the previous modeling axis's position:
import c4d from c4d import gui # Welcome to the world of Python myownID = 123456 # Main function def main(): if op is None: return if doc is None: raise ValueError("doc isn't initialized !!!") #retrieves the stored matrix inside the document's BaseContainer mmt = doc[myownID] # sets the current modeling axis matrix op.SetModelingAxis(mmt) # Pushes an update event to Cinema 4D c4d.EventAdd() # Execute main() if __name__=='__main__': main()
But I'm not sure if it's this position you want to restore.
Cheers,
Manuel -
Hi:
Unfortunately, once the modeling axis is set, there is no way to recover.If I click on any point, the coordinates are the same.Even if you create a new polygon object and click on any point, the coordinates are the same.The coordinates of the entire file will not be refreshed unless a new document is created, but the script will still be able to retrieve the coordinate data normally。
Coordinates are no longer refreshed and are consistent. -
hi,
Do you mean with the code i provided ?
Do you have some step procedure / code to reproduce this behavior ?
Witch version of Cinema4D are you using ?Cheers,
Manuel -
HI:
The modeling axis cannot be restored to its default state using the following sample code.Create a new cube object, collapse, and select any point.The world coordinates of points are all 0.
"""Script Manager script. Swizzles the modeling axis of the selected polygon object when run. As a side effect the active tool is changed to the LiveSelection tool and set into "Free" mode. You will have to pretty up the script yourself if you want a more streamlined experience. """ import c4d def swizzle_modelling_axis(doc, op): """Swizzles the modeling axis of the passed object. Args: doc (c4d.documents.BaseDocument): The active document. op (c4d.PolygonObject): A node in the active document. Raises: TypeError: When op is not a PolygonObject. """ def swizzle_matrix(m): """Swizzles a matrix, pushing in numerical and looping order of its components (e.g. v1, v2, v3 becomes v3, v1, v2). """ return c4d.Matrix(off=m.off, v1=m.v3, v2=m.v1, v3=m.v2) # Sort out non-polygon-objects. if not isinstance(op, c4d.PolygonObject): msg = ("swizzle_modelling_axis() requires a polygon object. " "Received: {type}.") raise TypeError(msg.format(type=type(op))) # We need the axis to be free in order to be able to modify the axis. # For that we select the live selection tool and set it to free mode. doc.SetAction(c4d.ID_MODELING_LIVESELECTION) plugin = c4d.plugins.FindPlugin(c4d.ID_MODELING_LIVESELECTION, c4d.PLUGINTYPE_TOOL) if plugin is None: return else: plugin[c4d.MDATA_AXIS_MODE] = c4d.MDATA_AXIS_MODE_FREE # Get the modeling axis, swizzle it and write it back. axis = swizzle_matrix(op.GetModelingAxis(doc)) op.SetModelingAxis(axis) op.Message(c4d.MSG_UPDATE) def main(): """Entry point. """ swizzle_modelling_axis(doc, op) c4d.EventAdd() if __name__=='__main__': main()
-
hi,
I can't reproduce that, what version are you using ?the only moment where a coordinates could be 0 is if the point and the object's pivot are sharing the same coordinates AND you have the "Enable Axis" enable.
(or you are in object's rel or abs coordinate and the point is at the same position of the pivot's object.
As if you were at the same time in object's mode and in point mode. (moving the object's pivot point and the modeling axis at the same time)So this look like a bug.
by the way, what do you call the "default state" ? The last modeling axis position ? the position when you selected the polygon ?
Cheers,
Manuel