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).
@m_magalhaes Got it, thanks :)
Hi, I've just tested this script in R23. It doesn't work :( One of my own scripts cannot work without this function. Guys, you're really awesome! I love C4D, and hope you can fix it :D
May be I can help somehow? I can upload the example scene, if you need it.
Hello guys, I rewritten script UV2PhongEdges (weird name, I know :D) from scratch. Now it should works much faster. Also UNDO finally works, yyyeeeey!
UV2PhongEdges
You can download it here https://github.com/rocketjump4d/UV2PhongEdges
And here is an example https://vimeo.com/447775062
Also, if you just need to get edges indexes of all UV borders you can use this code:
import c4d from c4d import utils def GetUVBorders(obj): edgesIndexes = set() abcd = tuple("abcd") tuvw = obj.GetTag(c4d.Tuvw) nbr = utils.Neighbor() nbr.Init(obj) # Create empty set for `edgesVV` # In this case `edgeVV` means `Edge between Vertex0 and Vertex1 (edgeVertexVertex)` # edgeVV is just a tuple(v0, v1), where v0 is index of the first vertex # and v1 is the second one allEdgesVV = set() for i in xrange(obj.GetPointCount()): # Find neighbor vertex for this one neighborIndexes = nbr.GetPointOneRingPoints(i) for ni in neighborIndexes: edgeTuple = (i, ni) allEdgesVV.add(edgeTuple) # At this point I've got a set of all `edgesVV` of the object # Something like this: # (0, 3) # (0, 5) # (5, 1) for edgeVV in allEdgesVV: # Find neighbour polygons for this edge # I called them polyA and polyB polyAIndex, polyBIndex = nbr.GetEdgePolys(edgeVV[0], edgeVV[1]) polyA = obj.GetPolygon(polyAIndex) if polyBIndex is c4d.NOTOK: # There is no polyB. It means that this edge is border of the object # eiA stands for `Edge Index in polyA for current edgeVV` eiA = polyAIndex * 4 + polyA.FindEdge(edgeVV[0], edgeVV[1]) edgesIndexes.add(eiA) continue polyB = obj.GetPolygon(polyBIndex) # piA0 stands for `Point Index in polyA for vertex edgeVV[0]` # the same for others piA0 = polyA.Find(edgeVV[0]) piA1 = polyA.Find(edgeVV[1]) piB0 = polyB.Find(edgeVV[0]) piB1 = polyB.Find(edgeVV[1]) # Replace "d" (3) to "c" (2) if polygon is triangle if polyA.IsTriangle() and piA0 == 3: piA0 = 2 if polyA.IsTriangle() and piA1 == 3: piA1 = 2 if polyB.IsTriangle() and piB0 == 3: piB0 = 2 if polyB.IsTriangle() and piB1 == 3: piB1 = 2 # Get UV coordinates for each point in each polygon uvCoordA0 = tuvw.GetSlow(polyAIndex)[abcd[piA0]] uvCoordA1 = tuvw.GetSlow(polyAIndex)[abcd[piA1]] uvCoordB0 = tuvw.GetSlow(polyBIndex)[abcd[piB0]] uvCoordB1 = tuvw.GetSlow(polyBIndex)[abcd[piB1]] if uvCoordA0 != uvCoordB0 or uvCoordA1 != uvCoordB1: eiA = polyAIndex * 4 + polyA.FindEdge(edgeVV[0], edgeVV[1]) eiB = polyBIndex * 4 + polyB.FindEdge(edgeVV[0], edgeVV[1]) edgesIndexes.add(eiA) edgesIndexes.add(eiB) return edgesIndexes
Let me know if you find bugs. Btw, sorry any mistakes. My English is... meh
Hello guys, It's something weird with MCOMMAND_MIRROR in S22.
MCOMMAND_MIRROR
This script (thanks to m_adam) duplicates and mirrors the object.
import c4d def main(): # Checks if selected object is valid if op is None: raise ValueError("op is none, please select one object.") # Defines some general settings, take care MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE settings = c4d.BaseContainer() settings[c4d.MDATA_MIRROR_DUPLICATE] = True settings[c4d.MDATA_MIRROR_SELECTIONS] = True settings[c4d.MDATA_MIRROR_ONPLANE] = True settings[c4d.MDATA_MIRROR_WELD] = True settings[c4d.MDATA_MIRROR_TOLERANCE] = 0.01 # Corresponds to MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE value = 1000.0 system = 0 # 0 = Object, 1 = World plane = 1 # 0 = XY, 1 = ZY, 2 = XZ if not 0 <= system < 2: raise ValueError("System can only be 0 or 1") # Buffer position vector pos = c4d.Vector() # Calculates Local (Object) coordinates if system == 0: globalMatrix = op.GetMg() if plane == 0: pos = globalMatrix.v3 elif plane == 1: pos = globalMatrix.v1 elif plane == 2: pos = globalMatrix.v2 settings[c4d.MDATA_MIRROR_POINT] = globalMatrix.off + pos * value settings[c4d.MDATA_MIRROR_VECTOR] = pos # Calculates World coordinates elif system == 1: if plane == 0: pos = c4d.Vector(0.0, 0.0, 1.0) elif plane == 1: pos = c4d.Vector(1.0, 0.0, 0.0) elif plane == 2: pos = c4d.Vector(0.0, 1.0, 0.0) settings[c4d.MDATA_MIRROR_POINT] = pos * value settings[c4d.MDATA_MIRROR_VECTOR] = pos # Send the Modeling Operation res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_MIRROR, [op], c4d.MODELINGCOMMANDMODE_ALL, settings, doc) c4d.EventAdd() if __name__ == "__main__": main()
However, if I change
settings[c4d.MDATA_MIRROR_DUPLICATE] = True
to
settings[c4d.MDATA_MIRROR_DUPLICATE] = False
Script doesn't make anything. In R20 it works. Is it ok? Is there any way to just mirror the object without duplicate it?
P.S. Also, if I use Mirror (https://help.maxon.net/index.html#5633) with unchecked Duplicate Points everything works (in S22).
Mirror
Duplicate Points
Cinema 4D S22.118 Windows 10
Hi @m_adam Thank you for your reply. It works perfectly!
Hi there, I'm trying to mirror object via SendModelingCommand(c4d.MCOMMAND_MIRROR, ..) But I cann't understand how to change a coordinate system. According to the documentation this options is called MDATA_MIRROR_SYSTEM and it's int type. Its description says Coordinate system. (See dialog.) I believe it is the dialog:
SendModelingCommand(c4d.MCOMMAND_MIRROR, ..)
MDATA_MIRROR_SYSTEM
int
Coordinate system. (See dialog.)
It seems like 0 means Object, 1 - World, 2 - Screen. I tried different values from 0 to 30, but it didn't take any effect.
The code I'm using:
settings = c4d.BaseContainer() settings[c4d.MDATA_MIRROR_SYSTEM] = 0 res = utils.SendModelingCommand(c4d.MCOMMAND_MIRROR, [obj], c4d.MODELINGCOMMANDMODE_ALL, settings, doc)
I cannot change MDATA_MIRROR_PLANE either. There is no additional information in the documentation. Drag'n'drop for these fields doesn't work. It's strange, because it works perfectly for other tools.
MDATA_MIRROR_PLANE
I found this post (from 2011) https://plugincafe.maxon.net/topic/5497/5516_mirror-tool-bug It seems that bug is still alive :(
Version: R20 Platform: Windows
Cheers
Hi everyone!
When C4D is in Polygon mode Grow selection can be done using SendModelingCommand e.g.
Grow selection
SendModelingCommand
utils.SendModelingCommand( c4d.MCOMMAND_SELECTGROW, [op], c4d.MODELINGCOMMANDMODE_POLYGONSELECTION, c4d.BaseContainer(), doc )
After that, selection grows to neighbour polygons. Everithing is ok. However, when active mode is UV Polygon then code above select neighbour polygons the same way how it was in previous case. Sometime it's ok, but not always.
The second way to grow selection is to use CallCommand
CallCommand
c4d.CallCommand(12558, 12558) # Grow Selection
In this case selection grows correctly in both modes. I'll show an example. There is a simple sphere that separated by UVs in the middle. So it has 2 UV islands.
From 1 selected polygon (the first image) I want to get the result which is shown on the last image. But I don't know how to get it without CallCommand Sorry for mistakes. English is not my szcznek language Cheers
Thank you very much guys! I think that plugin will be better solution then script in this case. Cheers
Hi @mp5gosu, thank you for your feedback! Yep, it has Undo problem. I assume, it's because the script uses CallCommand. And there are 2 places where I still don't understand how to avoid this :(
the selection should be restored after the process Thank you for this remark. I'm gonna fix it asap. Cheers.
the selection should be restored after the process
EDIT: I've fixed the script. Now it restores the selection after the process.
I've wrote it by myself :) Its presentation is here: https://plugincafe.maxon.net/topic/11336/script-harden-edges-of-all-uv-borders-break-phong-shading May be it'll be useful for someone Cheers
Hi, I'd like to present you a simple script. It let you automatically select all UV borders and break their Phong shading, that might be useful for game modeling, especially with hardsurface props. More info about hard edges - http://www.polycount.com/forum/showthread.php?t=107196
Unfortunately, the 'Texture View' window must be opened at least once for properly work :( Just close 'Texture View' and continue work.
Video: https://vimeo.com/317072443
Download link: https://github.com/rocketjump4d/UV2PhongEdges
I've wrote a script which must make some calculations only once and then use these values until C4D is closed. After C4D is opened again the script must recalculate values again, but only once. It's not a plugin, but only python script. Is it possible to realize? Cheers
Hi, guys! For Maya and 3ds max there are super useful scripts to harden all edges that are attached to UV borders. But I cannot find something like this for C4D. Does it exist?
Example MEL script: https://jonathonstewart.blogspot.com/2012/10/script-harden-edges-of-all-uv-borders.html
I hope posted this question in right sub-forum. Sorry for ma poor Englisch.
Hi @m_adam, thank you for your answer! I'll try command line. Cheers
Hello! It seems like Cinema 4D uses more plugins then c4dpy. I've written (copypasted) this code:
import c4d def main(): importPlugins = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_SCENELOADER, True) for p in importPlugins: print('{} : {}'.format(p.GetName(), p.GetID())) if __name__=='__main__': main()
If it runs within Cinema 4D it returns this list:
3D Studio (*.3ds) : 1001037 Alembic (*.abc) : 1028081 BVH (*.bvh) : 1001048 CATIA (*.CATPart *.CATProduct *.cgr) : 1039778 Cinema 4D (*.c4d) : 1001025 COLLADA 1.4 (*.dae) : 1022315 COLLADA 1.5 (*.dae) : 1025754 DEM (*.dem) : 1001046 DWG (*.dwg) : 1021372 DXF (*.dxf) : 1001035 FBX (*.fbx) : 1026369 IGES (*.igs *.iges) : 1039779 Illustrator (*.ai) : 1001045 JT (*.jt) : 1039780 Lightwave (*.lws) : 1001043 Lightwave Object (*.lwo) : 1001044 MeshObject JSON Asset : 1040819 SKP (*.skp) : 1033845 Solidworks (*.SLDPrt *.SLDAsm *.SLDDrw) : 1039781 STEP (*.stp *.step *.p21) : 1039777 STL (*.stl) : 1001020 Updater loader : 450000233 Volume (*.vdb) : 1039864 VRML 2 (*.wrl) : 1001033 Wavefront OBJ (*.obj) : 1030177
However when it runs via console
c4dpy *pathToScript*
it logged this one
3D Studio (*.3ds) : 1001037 Alembic (*.abc) : 1028081 BVH (*.bvh) : 1001048 CATIA (*.CATPart *.CATProduct *.cgr) : 1039778 Cinema 4D (*.c4d) : 1001025 DEM (*.dem) : 1001046 DXF (*.dxf) : 1001035 IGES (*.igs *.iges) : 1039779 Illustrator (*.ai) : 1001045 JT (*.jt) : 1039780 Lightwave (*.lws) : 1001043 Lightwave Object (*.lwo) : 1001044 MeshObject JSON Asset : 1040819 SKP (*.skp) : 1033845 Solidworks (*.SLDPrt *.SLDAsm *.SLDDrw) : 1039781 STEP (*.stp *.step *.p21) : 1039777 STL (*.stl) : 1001020 Updater loader : 450000233 Volume (*.vdb) : 1039864 VRML 2 (*.wrl) : 1001033 Wavefront OBJ (*.obj) : 1030177
It's a little bit shorter. And there is no FBX :( Is it bug? May be I do something wrong?
I use Cinema 4D R20.030 on Windows.
P.S. I'm sorry for any grammar mistakes. P.P.S. C4D developers! You're awesome! C4D is just amazing! I really love it!