@m_magalhaes Yes, exactly!
blastframe
@blastframe
Posts made by blastframe

Ability to set DLG_TYPE_ASYNC Width & Height
Hello,
I have several Command Plugins whose asynchronous GeDialogs are opening at some different sizes: sometimes far too large for its content which looks quite bad and requires the user to resize to use the plugin with the C4D scene.return myDialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, xpos=2, ypos=2, pluginid=PLUGIN_ID, defaultw=560, defaulth=560)
As I don't believe it's currently possible, I'd like to request the ability to set a size for the GeDialog DLG_TYPE_ASYNC window. This has come up in the forum and it seems like it'd be a terrific feature for developers.
Re: open DLG_TYPE_ASYNC always with default size
Re: Resize dialog after LayoutFlushGroup(id)
Re: Sizing Plugin DialogsThank you!

RE: Flat UV Projection in Python
Thank you very much @zipit ! That works great.

Flat UV Projection in Python
Hello!
I'm creating a polygon object in an ObjectData plugin. I would like to layout its UVs with Flat projection (similar to BodyPaint's Flat Projection button). I found this post with code taken from this post on the forum. This seems to be what I need, but it's old and I ran into some issues with methods unavailable to the Python API. Here is my port of the code to Python:import c4d,math #This code creates the equivalent to the flat mapping button in the BP UV options #Define a value macro to be used several times later on SIGDIG=5.0 def TrimDecimal(num, digits): n = None n = num * math.pow(10.0, digits) n = math.copysign(1, n) * abs(math.floor(n + 0.5)) return n / math.pow(10.0, digits) def FrontalMapUVs(op, mg): if op is None: return false numFaces = op.GetPolygonCount() numVerts = op.GetPointCount() pVerts = op.GetPointW() #GetPointW doesn't exist in the Python API pPolys = op.GetPolygonW() pUVTag = op.MakeVariableTag(c4d.Tuvw, numFaces) if pUVTag is None: return false pUVHndl = pUVTag.GetDataAddressW() #GetDataAddressW doesn't exist in the Python API if pUVHndl is None: return false lenxinv, lenyinv, lenzinv = None, None, None vMin = c4d.Vector(100000.0) vMax = c4d.Vector(100000.0) for ndx in range(numVerts): pt = pVerts[ndx] * mg #pVerts won't work because GetPointW doesn't exist if pt.x < vMin.x: vMin.x = pt.x if pt.x > vMax.x: vMax.x = pt.x if pt.y < vMin.y: vMin.y = pt.y if pt.y > vMax.y: vMax.y = pt.y if pt.z < vMin.z: vMin.z = pt.z if pt.z > vMax.z: vMax.z = pt.z mapSize = c4d.Vector(abs(vMax.x  vMin.x),abs(vMax.y  vMin.y),abs(vMax.z  vMin.z)) mapCenter = c4d.Vector(vMin.x+(mapSize.x*0.5),vMin.y+(mapSize.y*0.5),vMin.z+(mapSize.z*0.5)) if mapSize.x != 0.0: lenxinv = 1.0 / mapSize.x else: lenxinv = 0.0 if mapSize.y != 0.0: lenyinv = 1.0 / mapSize.y else: lenyinv = 0.0 if mapSize.z != 0.0: lenzinv = 1.0 / mapSize.z else: lenzinv = 0.0 # Walk the list of polygons and map the UVs for ndx in range(numFaces): """ Not sure what to do here as UVWStruct & UVWTag.Get do not exist in the Python API uvw = c4d.UVWStruct() pUVTag.Get(pUVHndl, ndx, uvw) """ pt_a = (pVerts[pPolys[ndx].a]  mapCenter) + mg.off pt_b = (pVerts[pPolys[ndx].b]  mapCenter) + mg.off pt_c = (pVerts[pPolys[ndx].c]  mapCenter) + mg.off pt_d = (pVerts[pPolys[ndx].d]  mapCenter) + mg.off uvw.a.x = TrimDecimal((pt_a.x*lenxinv)+0.5, SIGDIG) uvw.a.y = TrimDecimal((pt_a.y*lenyinv)+0.5, SIGDIG) uvw.b.x = TrimDecimal((pt_b.x*lenxinv)+0.5, SIGDIG) uvw.b.y = TrimDecimal((pt_b.y*lenyinv)+0.5, SIGDIG) uvw.c.x = TrimDecimal((pt_c.x*lenxinv)+0.5, SIGDIG) uvw.c.y = TrimDecimal((pt_c.y*lenyinv)+0.5, SIGDIG) uvw.d.x = TrimDecimal((pt_d.x*lenxinv)+0.5, SIGDIG) uvw.d.y = TrimDecimal((pt_d.y*lenyinv)+0.5, SIGDIG) """ commented out because of UVWStruct missing above """ #pUVTag.Set(pUVHndl, ndx, uvw) return true if __name__=='__main__': FrontalMapUVs(op,op.GetMg()) #I'm sending the selected object's global matrix, but I'm not sure if it's correct to do.
I noted some of the issues in the code's comments, but to sum up, I couldn't get it to work because these were missing in Python:
 PolygonObject.GetPointW: Gets the start of the writable points array.
 UVWTag.GetDataAddressW: Gets a handle to the writable UVW data.
 UVWTag.Get: Gets the UVW coordinates for a polygon.
 UVWTag.Set: Sets the UVW coordinates for a polygon.
 UVWStruct: Holds UVW tag variable coordinates data.
I also didn't know which Global Matrix I should send to the
FrontalMapUVs
function. I'd assume it wasop
, but it seems strange for that to be a parameter if it's already acceptingop
.If there are no Python equivalents to these missing C++ methods, is there another way to do Flat UV Projection in Python with an ObjectData plugin?
Thank you!

RE: Moving a Point Along an Arc by Distance from another Point
@zipit My sincerest gratitude for your help. Not only did you get my project unblocked, but you answered my followup questions. I have learned a lot from you. Thank you!

RE: 'SetRealTag' Request
@m_magalhaes Hi Manuel! Thanks for the update.

RE: Moving a Point Along an Arc by Distance from another Point
@zipit It's such a blessing to have you in these forums. You know a lot and are active in helping. Thank you!
Hahaha! You are right about my angle computation when you demonstrated how simple this should be. I found the formula online in a Javascript fiddle and didn't understand it, but it did create circular motion. The
clamp
function call is making sure themath.acos
gets values between 1 & 1 as I was getting errors.Regarding a few of your comments:
 Thank you for the detailed explanation in the comments! You made things much clearer and the program much shorter !
 In your code comment you mention spherical interpolation between the arc segment. Is that the same as the quadratic bezier interpolation from the example you provided (code below)? I think that's also called slerp? I would love to learn more about this subject if it's as easy as you say. Do you have a recommendation for resources that would apply to 3D in Python? My math skills are not anywhere near yours: I don't know how I'd go about translating what you did with interpolation to two points & arc length.
samples = 6 for i in range(samples): t = float(i)/(samples  1) # The quadratic bezier interpolation at t. p = a * (1t) ** 2 + b * 2 * (1t) * t + c * t ** 2 # Cinema also has two spline functions in c4d.utils, CalcSpline ...
 How do I get the points to stop at the limits of the arc? In this case, it would seem to be limiting the angle to 0 and
math.pi
, but what if the start & end angles are different?  If I'm not to use
c4d.Vector.GetDistance
, how would you recommend I get the geodesic norm? I found modules online like geopy, but I'd rather do it with standard Python.

Moving a Point Along an Arc by Distance from another Point
Hello,
I have a question that involves trigonometry if anyone out there can help in that area. I am using length units to place points along an arc and I want to make one point's distance relative to the other.In this image, I am plotting a point (1) on an arc based on the arc length which I'm determining with this arccosine equation followed by the parametric equation for a circle.
angle = math.acos(1  math.pow(d / radius, 2) / 2) #d is distance newX = cx + radius * math.cos(angle) #cx is the arc's center x newY = cy + radius * math.sin(angle) #cx is the arc's center y
I'm then creating a second point (2) based on the position of 1. I'm adding point 2's distance to the distance of Point 1.
When I run
c4d.Vector.GetDistance(point1,point2)
, I would expect the distance to be the same as Point 2's distance, but it is not. Can anyone help me control Point 2's distance from Point 1 so that it's the same distance? I've attached my scene file and Python tag code if it's helpful. As always, thank you!import c4d,math def clamp(n, minn, maxn): return max(min(maxn, n), minn) def PosByDistance(cx, cy, d, radius): a = 1  math.pow(d / radius, 2) / 2 a = clamp(a, 1, 1) angle = math.acos(a) newX = cx + radius * math.cos(angle) newY = cy + radius * math.sin(angle) return c4d.Vector(newX, newY, 0) def draw(bd): node = op.GetObject() bd.SetMatrix_Matrix(op=node, mg=node.GetMg(), zoffset=4) bd.SetPointSize(10) bd.SetPen(c4d.Vector(0.5, 0.5, 0.5)) off = node.GetMg().off radius = node[c4d.PRIM_ARC_RADIUS] dist = op[c4d.ID_USERDATA,2] point1 = PosByDistance(off.x,off.y,dist,radius) bd.DrawHandle(point1, type=c4d.DRAWHANDLE_CUSTOM, flags=0) p2offset = op[c4d.ID_USERDATA,4] point2 = PosByDistance(off.x,off.y,dist+p2offset,radius) bd.SetPen(c4d.Vector(0, 1, 0)) bd.DrawHandle(point2, type=c4d.DRAWHANDLE_CUSTOM, flags=0) op[c4d.ID_USERDATA,3] = str(round(c4d.Vector.GetDistance(point1,point2),2)) def main(): pass

RE: How to fillet a ObjectData edge in Python?
@zipit Absolutely incredible work! So elegant! Thank you very much
@m_adam Thank you for the reply and confirmation!

RE: How to fillet a ObjectData edge in Python?
Hello @zipit ! Thanks again for the message.
Filleted edges going different directions do not meet, thank God!
If you take a look at the Python tag in the scene file I attached above, I had already done all of the steps in your list. There appears to be some exceptions though depending on the positions of the three points making the corner:
 In my scene example, the arc spline works with the start & end angle correctly, but not the arc points.
 When the startAngle is negative and the endAngle is positive, the arc spline flips (and the arc points are still incorrect).
 How can I limit the size of the radius based on the available space?
** When both the startAngle & endAngle are negative, the arc spline and arc points are correct.
As mentioned in the first two posts, those are the issues for which I'm seeking help.