Followme - hang
-
Hi , Everyone ,
everytime i run the following script , my computer was hang (same in a few computers) , if i remove pts[5] to pts[9] , it can run properly , i found the problems is "followme" causing the issue.
I'm thinking this is the problem of Sketchup , is there anyone have the same problem ?
=================
def draw_all_object_0001
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [3932.75984252 , 5122.173228346 , 0]
pts[1] = [3833.940944882 , 4902.881889764 , 0]
pts[2] = [3857.169291339 , 4822.566929134 , 0]
pts[3] = [3234.334645669 , 3693.433070866 , 0]
pts[4] = [3310.318897638 , 3651.307086614 , 0]
pts[5] = [3227.641732283 , 3501.307086614 , 0]
pts[6] = [2355.594488189 , 3982.409448819 , 0]
pts[7] = [3048.114173228 , 5221.385826772 , 0]
pts[8] = [3405.988188976 , 5023.748031496 , 0]
pts[9] = [3566.618110236 , 5314.692913386 , 0]p2vector = [0,1,0] ptvertex = pts[0] vectorX = Geom::Vector3d.new p2vector vectorX2 = vectorX.normalize! edgesX = entities.add_circle ptvertex, vectorX2, 19.68503937 faceX = entities.add_face edgesX curve = entities.add_curve pts begin status = faceX.followme curve #sketchup hang here rescue UI.messagebox $!.message end end UI.menu("PlugIns").add_item("Draw -- myshape") { draw_all_object_0001 view = Sketchup.active_model.active_view new_view = view.zoom_extents }
========================
-
Why are you passing co-ordinates with 9 decimal places?
Note: Sketchup has an internal limit of 0.001 inch (0.0254mm)
-
Even with the coordinate value at more sensible dps it still hangs at the followme.
A very puzzling phenomenon...
If you make the face and the path, then stop before the followme code runs [just add a # in front of the code]; when you can use a manual followme on the parts and it's fine, but if you get references to the face and to the curves edges [using selection etc] and do a coded followme inside the Ruby Console it hangs again !
Reducing the points' values by 1/10 or *10 has no affect - it still hangs...
It is possible to have followme paths consisting of dozens of connected edges, so I fail to see what is causing the issues here with just these 9 coplanar and non-intersecting edges...
There are no tight bends or short lengths to cause 'small facet issues' etc, but they shouldn't cause the hang anyway - they just leave missing small facets on completion.
The fact that is will successfully do a manual followme with pre-pick path and clicked face is plain weird...
It's is a complete mystery to me why it fails as it does...
Any others got ideas ??Incidentally to place the circle perpendicular to the first edge use
vectorX2=pts[1].vector_to(pts[0])
instead of the current way which skews it slightly...
Also you could reduce the number of facets in the circle by adding the additional optional final argument - e.g.,8
...
I'd also recommend encapsulating your methods inside your own module, and adding the new geometry into a new group.entities, to avoid potential clashes with other preexisting geometry - you can always use group.explode at the end if desired. [Once we have this working]
-
Playing around with this issue a bit.
The followme API entry says the argument is AN edge object (singular.)
So, when I changed the argument to followme, to a single edge, ie, the first segment in the curve, it extruded the circle up to the first bend. No problem.So then I tried wrapping that in a
curve.edges.each
block, but I got a popup error saying "Reference to 'Deleted Entity'."I tried passing the whole curve to followme, also the
curve.edges
array, and even *(curve.edges), but still no joy. -
Ok I solved this.
You were overloading the followme method. Your co-ordinates to too high in precision, and I assume you wanted to specify mm.
I added an inputbox to the code, to set the size and segments for the face.
Added TIG's suggestion of creating the tube within a group (which is returned by the method, upon success.)
Module wrapped.
Undo Operation wrapped.
All numbers are specified in mm, and truncated at 0.001" -
Hi , Dan
thank you very much , your script is work , but unfortunately , all the value i'm using is "inch" instead of "mm"
once i change your script to "inch" , it still hangs , but it's fine if i run "followme" manually.
-
A Dan says... if you specify the values to such a degree of accuracy, that's way beyond what Sketchup needs, then it somehow overloads it and it fails.
If you make your numbers with fewer decimal places - as Dan indicated - then it will work.
So instead of 1.23456789 use 1.235
Any more numbers than 3 after the inch d.p. is superfluous and causes the issues.
Dan assumed mm but if it's inches it's the same principle...
-
Hi , TIG & Dan
thank you for you reply , to confirm this is not the problem of decimal place , i've removed all the decimal place from the array, but it still hang. I found the major problem is the diameter of cicle , if i change it to 50mm it will hang. (but if you run "followme" manually , it won't hang even you set the diameter to 100mm)
#======================================================
def draw_all_object_0001
model = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [393 , 512 , 0]
pts[1] = [383 , 490 , 0]
pts[2] = [385 , 482 , 0]
pts[3] = [323 , 369 , 0]
pts[4] = [331 , 365 , 0]
pts[5] = [322 , 350 , 0]
pts[6] = [235 , 398 , 0]
pts[7] = [304 , 522 , 0]
pts[8] = [340 , 502 , 0]
pts[9] = [356 , 531 , 0]p2vector = [0,1,0]
ptvertex = pts[0]
vectorX = Geom::Vector3d.new p2vector
vectorX2 = vectorX.normalize!
edgesX = entities.add_circle ptvertex, vectorX2, 20.mm , 8 # change to 50.mm will hang
faceX = entities.add_face edgesXcurve = entities.add_curve pts
begin
status = faceX.followme curve #sketchup hang here
rescue
UI.messagebox $!.message
end
endUI.menu("PlugIns").add_item("Draw -- myshape") {
draw_all_object_0001
view = Sketchup.active_model.active_view
new_view = view.zoom_extents
}#=========================================================
-
Convert your pt arrays to REAL
Geom::Point3d
instances like I showed in the example, BEFORE passing them to thefollowme()
method.If you do not want mm, then just remove
.mm
calls from the code, and change the labels for the inputbox. -
Hi , Dan
unfortunately , i've removed all the ".mm" in your code , if the diamter of the circle is 50 mm ,
this will hang , but it's fine if the diameter is 20mm , this is the reason why i said it seem to be related to the diameter of the circle instead of decimal place or array type.
Advertisement