Jump to content
Developer Wiki and Function Reference Links ×

Get Circle Node


DomC

Recommended Posts

Maybe i just need a break or there is something strange with the "Get Circle" Node. The Radius is not as expected.

rads = abs(x1)+abs(y1) hmm that can't work I think :grin:

Original Code:

points = vs.GetBBox(h)
top_left = points[0]
bottom_right= points[1]
x1 =top_left[0]
y1 = top_left[1]
x2 =  bottom_right[0]
y2 =  bottom_right[1]
final_x = (x1 + x2)/2
final_y = (y1 + y2)/2
rads =  abs(x1)+abs(y1)
center = (final_x,final_y)
self.Params.centerPt.value = center
self.Params.radius.value = rads

Modified Code:

	points = vs.GetBBox(h)
top_left = points[0]
bottom_right= points[1]
x1 =top_left[0]
y1 = top_left[1]
x2 =  bottom_right[0]
y2 =  bottom_right[1]
x = (x2 - x1)
y = (y1 - y2)
rads =  x/2
center = (x2-x/2,y1-y/2)
self.Params.centerPt.value = center
self.Params.radius.value = rads

Maybe there is a better solution ... but for now, it seems to work

Link to comment
  • Marionette Maven

Hi Dom!

In my version of SP2 this was already changed.

This is the code in the release of SP2:

def RunNode(self):
h = self.Params.circle.value
points = vs.GetBBox(h)
top_left = points[0]
bottom_right= points[1]
x1 =top_left[0]
y1 = top_left[1]
x2 =  bottom_right[0]
y2 =  bottom_right[1]
final_x = (x1 + x2)/2
final_y = (y1 + y2)/2
#rads =  abs(x1)+abs(y1) #TODO: remove
rads = (x2 - x1)/2
center = (final_x,final_y)
self.Params.centerPt.value = center
self.Params.radius.value = rads

Which with my brief testing works correctly.

(Also, notice the "#rads = abs(x1)+abs(y1) #TODO: remove", it appears whoever fixed this way back when never completely removed the comment :P I'll check to see if I can take this line out soon to clean it up a bit.)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...