C4D might have been 'messed up' based on my prior attempts. I've restarted it and may be making progress.
Best posts made by .del
found it!!! I had to float('0.5')
Latest posts made by .del
Thanks for the info and adding the tag. I totally forgot that the Cafe' merged. I'm so used to approaching from my view. I actually answered somebodies question yesterday and at the very end saw the C++ tag and hit delete
Thanks for tips on the GUI. I was able to implement what I needed.
Hi - I'm currently making an attempt to better understand the gui.GeDialog stuff and ran across this in the sdk.
GeDialog.GroupBorder(self, borderstyle)
Sets the border type of the current group, and displays the title in the border if possible.
GeDialog.GroupBorderNoTitle(self, borderstyle)
Sets the border type of the current group, and displays the title in the border if possible.
Am I reading these wrong and haven't learned anything yet or should GroupBorderNoTitle have a different explanation and not have border title parameters listed below it?
Thanks for looking,
.del
HI -
Thanks for the response!
I'm going to go with the sendModelingCommand method. I never would have thought to put the CallCommand value in there.
This is really going to help me finish this script. I appreciate your help.
thank you,
.del
Hi - I'm wondering if the UV Peeler is accessible via python. I see it listed in the SDK but I'm not familiar with how to use it.
Can it be used with SendModelingCommand or bodypaint.CallUVCommand?
The documentation references C4DAtom.SetParameter() but I've never used this.
Any info that can push me in the right direction is appreciated.
thanks,
.del
@ferdinand Thank you so much for digging into this. I'll look at your example more and try quantitizing the numbers. In the meantime I had written a catch for the -1.1102230246251565e-16 to treat it as zero but it's probably not a very robust solution. I like your idea of rounding them off instead. I didn't fully understand what that number represented. I tried searching it but didn't get any useful results. I tried again today and now I see what it is. I must have had something else in my search field when I originally tried.
We have a script for creating atlases of textures and if the UV is outside of the bounds it gets placed incorrectly on the atlased texture. This new script is intended to catch those so they can be corrected before hand. I think rounding anything within two decimal places of zero will work for our needs.
Is there a way to change the tags for this this thread as it's not a bug report. I thought it was but it turns out it's not.
Thanks you for the help. It's greatly appreciated.
I've been able to confirm that if I take the suspect vertexes and change them from a value 1 to .99 and then change them back to 1 they no longer cause the problem.
Hi -
Thank you both for responding.
I searched my model group and found other models with vertexes at the bounding box corners and those did not get flagged by my script so your suggestion of a malformed UV or some sort of overflow might be what my issue is. The script also worked as expected on your plane.c4d file as well as a cube.
If the overflow value is consistent perhaps I can test for that and allow it to pass rather than flagging the model?
I'm attaching a scene file with two models made from the same template. Ones fails to pass the test while the other works. They are labeled accordingly.
I've also trimmed the script to focus on the bounding box part. It's not as elegant as yours by any means but I'm a self admitted butcher of code. Just trying to make tools to streamline our workflow. They aren't pretty but they help us get home at the end of the day and I'm appreciative that the sdk is available. Please keep that in mind as you stumble through my vomit pile of a script. My code is not Pythonic.
Thanks for looking at my stuff.
.del
import c4d
import os
import math
from c4d import gui
from c4d import Vector
from c4d import bitmaps
from copy import copy
from c4d.modules import bodypaint
#####
#Start the clean up tasks to prepare for exporting to the library.
doc.SetMode(c4d.Mmodel)
dObjects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
if dObjects == []:
message = "You must select at least one object"
c4d.gui.MessageDialog(message, c4d.GEMB_OK)
else:
c4d.StatusSetSpin()
c4d.StatusSetText("Running Python Script")
isolate = False
for obj in dObjects:
if obj.CheckType(c4d.Opoint):
############################
# check that UV is within bounds
#
uvTag = obj.GetTag(c4d.Tuvw)
polyCount = obj.GetPolygonCount()
polygons = obj.GetAllPolygons()
for poly in range(polyCount):
polygon = polygons[poly]
data = uvTag.GetSlow(poly)
print("poly" + str(poly) + str(data))
if polygon.IsTriangle(): #if the poygon is a triangle instead of a quad we need to delete the 4th key as that position data is skewed and throwing a false positive.
del data['d']
for vertex in data:
if data[vertex].x < 0 or data[vertex].x > 1:
print(data[vertex].x)
if data[vertex].y < 0 or data[vertex].y > 1:
print(str(poly) +" " +vertex)
print(data[vertex][1])
print(data)
c4d.StatusClear()
Hi -
I made a script that gets the vertex points of a UV and checks to see if they or within the 0,0 1,1 coordinate system. The script flags any vertex position less than 0 or greater than 1.
I print the output to the script manager identifying which polygon number it is as well as if it's the a, b, c, or d UV vertex. I also print out the full data dictionary for that polygon.
I have one model that is getting flagged by my script for having a vertex less than zero. As I was digging through my script and looking at the model with the Structure Manager pulled up I found an interesting thing. Any vertex that has a V value of 1 in the structure manager is coming through uvTag.GetSlow(poly) as a scientific notation value of -1.1102230246251565e-16. I am not seeing the same issue if the U value is equal to 1.
I took a screen shot of the Structure manager laid next to the python console so you can see what I mean.
Any ideas on how I can program around this?
Thanks,
.del
############################
# check that UV is within bounds
#
uvTag = obj.GetTag(c4d.Tuvw)
polyCount = obj.GetPolygonCount()
polygons = obj.GetAllPolygons()
for poly in range(polyCount):
polygon = polygons[poly]
data = uvTag.GetSlow(poly)#returns a dictionary {a: Vector( u, v, w), b: Vector( u, v, w), c: Vector( u, v, w), d: Vector( u, v, w)}
#print("poly" + str(poly) + str(data))
for vertex in data:
if data[vertex][0] < 0 or data[vertex][0] > 1:
print(data[vertex][0])
if data[vertex][1] < 0 or data[vertex][1] > 1:
print(str(poly) +" " +vertex)
print(data[vertex][1])
print(data)
Thanks Manuel. I was able to work that concept into the overall script.
Hi- I have a python script that adds projects to the render queue successfully but now I'd like to be able to enable the Team Render option for them. After reviewing the documentation I felt like BatchRender.SetUseNet(self, n, on) was going to be the answer but I havn't been able to get it to work.
In the main body of the script I set dBatch = c4d.documents.GetBatchRender().
Later in the script I call batchRender definition.
def batchRender(dFilePath, objName):
dBatchCount = dBatch.GetElementCount() #number of items already in the batch render
dBatchCount += 1
dBatch.AddFile(dFilePath +"/" + objName + ".c4d", dBatchCount)
####enable Team Render for item
dBatch.SetUseNet(dBatchCount,True)
The script doesn't return any errors but the Team Render box is never activated.
Any insight is appreciated.
Thanks,
.del