TIG's method of getting the vertices of a face worked for me.
Thanks everyone for the replies.
TIG's method of getting the vertices of a face worked for me.
Thanks everyone for the replies.
Is there any way to switch the start and end of an edge? I noticed that many times, loops don't go start to end/start of next line(see examples):
It also seems to mess up with Loop.convex?().
The "View" documentation page is almost completely blocked by the user comments section:
EDIT: Fixed.
ah, I completely missed that. Yes it is.
I'm getting an error "Object doesn't support this property or method." on this line:
button.addEventListener("click", function() { alert(message);} , true ) ;
Is anyone else with IE getting this?
@unknownuser said:
This works on a Mac: (Didn't test on IE)
For some reason, the alert box is popping up automatically, without adding the button.
However, this did work for me:
@thomthom said:
button.onclick = function() { alert(message); };
@thomthom said:
hmm... turns out that the string thing is a legacy way of doing it.
Yeah, I'm not the best keeping up with standards.
Anyways, I think that will do it for me. Thanks everyone for the replies.
I've edited the top post to reflect the changes you suggested.
It is showing the exact same behaviour, it adds the button properly, but doesn't trigger.
I am trying to create a dynamic web page through javascript. Everything is working except for the "onclick" event for buttons.
here is an example of what I'm doing:
class WebTest
@@webDialog = UI;;WebDialog.new("This is a test",true,"Test",250,250,250,250,true)
html ="
<html>
<head>
<script>
function addButton()
{
body = document.body;
button = document.createElement('input');
button.type = 'button';
button.value = 'Click Me';
var message = 'I am working';
button.onclick = 'alert(message);';
button.id = 'btn1';
body.appendChild(button);
}
</script>
</head>
<body>
</body>
</html>"
@@webDialog.set_html(html)
def initialize
@@webDialog.show
end
def self.addButton
@@webDialog.execute_script("addButton()")
end
end
to test it, copy and paste the following code into an .rb, and type WebTest.new
, then WebTest.addButton
into the console.
It doesn't work in the sketchup webdialog, but when I copy and paste the same code into a regular browser, it does:
javascript:body = document.getElementsByTagName('body')[0];button = document.createElement('input');button.setAttribute('type','button');button.setAttribute('id','btn1');button.setAttribute('value','Click Me');var message = 'I am working';button.setAttribute('onclick','alert(message)');body.appendChild(button);
does anyone have any ideas?
@dan rathbun said:
Is it possible to use sleep in a subthread, without pausing execution in the main thread?
(Note examples in the 'Pick-Axe' Ruby book, under Kernel.sleep and class Thread.)
It is possible, but very innacurate, because ruby threads only run while the ruby interpreter is running(commands are entered in the console, WebDialog is shown, Ruby Tool, etc.)
So one command might take half a second one time, and the next time take 2 seconds.
EDIT: I'm sure you know this already, but just putting it out in the open: Ruby threads don't act like native threads. If you are doing a lot in one thread, it'll slow down the other, and vice versa. See this:
http://en.wikipedia.org/wiki/Green_threads
My initial thought would be:
numSelectedInstances = (e.definition.instances & ss.to_a).length # & intersects two arrays
You'll probably want to stick around and see what the others say.
A "Selection" is a collection of entities (lines, faces, etc.)
In order to get the line, you have to get the first object in the Selection, since you only have one thing selected:
line = selection[0]
Then, once you have the line, you can get the start and end vertices like this:
vtxStart = line.start vtxEnd = line.end
To get the positions of the vertices, just type either: startPosition = vtxStart.position
or endPosition = vtxEnd.position
Hopefully this is clear enough to get you started.
@jim said:
I made this mistake just yesterday (with def), but
end
is a Ruby keyword and not such a good name for a variable.
I can get the instance I'm looking for, but I'm having problems getting the actual transformation, since it is also in edit mode, but not the current edit mode.
I was able to find instance.local_transform, but it is undocumented.
Basically, I'm trying to use an input point to iterate up the model to find the component's path, instead of drilling down to find it.
Is there any way to get the local transformation for a component that is not at the end of the active path?
For example, say I double click a component, and then double click a component inside that one. I want to find the local transformation of the first.
I'm pretty sure that the problem is that you were using win32ole from Ruby 1.9.
Sketchup only uses 1.8.
One other idea is to use the File class to get the string from the file, and then use set_html.
Do you know which version of Ruby you took the Win32api from?
I think the problem is that you define tr in a seperate place than you use it. try replacing tr with @tr.
Can anyone explain why (transformation1 * transformation2) isn't the same as (transformation2 * transformation1)?
Anyways, it looks like if you use move!, you have two options, from a practical standpoint:
instance.move!(newTransformation*instance.transformation)
, which is essentially the same as (instance.transform!(newTransformation)) and
instance.move!(instance.transformation*newTransformation)
, which will apply the transformation according to the component's axes.
is there any reason (transformation * transformation) won't work? I guess I'm a bit confused in what exactly you want.