sketchucation logo sketchucation
    • Login
    1. Home
    2. cjthompson
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ”Œ Easy Offset | Offset selected faces in SketchUp in positive and negative offsets. Download
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 19
    • Posts 151
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Switch direction of edge?

      TIG's method of getting the vertices of a face worked for me.

      Thanks everyone for the replies.

      posted in Developers' Forum
      C
      cjthompson
    • Switch direction of edge?

      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):

      What I expected.

      What the edge directions actually are.

      It also seems to mess up with Loop.convex?().

      posted in Developers' Forum
      C
      cjthompson
    • RE: New API doc - typos and questions

      The "View" documentation page is almost completely blocked by the user comments section:

      view_documentation.JPG

      EDIT: Fixed.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Trouble triggering javascript event from sketchup

      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?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Trouble triggering javascript event from sketchup

      @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.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Trouble triggering javascript event from sketchup

      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.

      posted in Developers' Forum
      C
      cjthompson
    • Trouble triggering javascript event from sketchup

      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&#058;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?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Timer &lt; 1.0 seconds ?

      @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

      posted in Developers' Forum
      C
      cjthompson
    • RE: Count instances in selection???

      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.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Selection start/end detection

      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.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Selection start/end detection

      @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.

      😳

      posted in Developers' Forum
      C
      cjthompson
    • RE: Model.edit_transform for parent

      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.

      posted in Developers' Forum
      C
      cjthompson
    • Model.edit_transform for parent

      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.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Win32ole.so procedure/load issue

      I'm pretty sure that the problem is that you were using win32ole from Ruby 1.9.

      Sketchup only uses 1.8.

      posted in Developers' Forum
      C
      cjthompson
    • RE: WebDialog set_file

      One other idea is to use the File class to get the string from the file, and then use set_html.

      posted in Developers' Forum
      C
      cjthompson
    • RE: [Bug]Win32api.so and Sketchup7

      Do you know which version of Ruby you took the Win32api from?

      posted in Developers' Forum
      C
      cjthompson
    • RE: Planes

      I think the problem is that you define tr in a seperate place than you use it. try replacing tr with @tr.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Matrix Multiplication in C[++]

      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.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Matrix Multiplication in C[++]

      is there any reason (transformation * transformation) won't work? I guess I'm a bit confused in what exactly you want.

      posted in Developers' Forum
      C
      cjthompson
    • RE: Create toolbar on the fly

      toolbar.show?

      posted in Developers' Forum
      C
      cjthompson
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 4 / 8