ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Dynamic non-component

    2
    0 Votes
    2 Posts
    245 Views
    TIGT
    I'm not sure what you're trying to achieve... This might help [a bit] - it traps errors .......... class MyEntitiesObserver < Sketchup;;EntityObserver def onChangeEntity(entity) width = entity.bounds.width.to_f model = Sketchup.active_model entities = model.active_entities pts = [] pts[0] = [0, 0, 0] pts[1] = [width, 0, 0] pts[2] = [width, width*2.0, 0] pts[3] = [0, width*2.0, 0] begin face = entities.add_face pts face.add_observer($mmmmmmmmmmmmmmmmmmmmm) entity.edges.each{|i| i.erase! if not e.edges[1]} rescue puts 'error' face.remove_observer($mmmmmmmmmmmmmmmmmmmmm) face.add_observer($mmmmmmmmmmmmmmmmmmmmm) end end end model = Sketchup.active_model entities = model.active_entities pts = [] pts[0] = [0, 0, 0] pts[1] = [1, 0, 0] pts[2] = [1, 2, 0] pts[3] = [0, 2, 0] face = entities.add_face pts $mmmmmmmmmmmmmmmmmmmmm=MyEntitiesObserver.new() face.add_observer($mmmmmmmmmmmmmmmmmmmmm) I suggest you rename your observer as something less obvious... i.e. others might have used it !
  • Text in the corner of a rendered image

    5
    0 Votes
    5 Posts
    334 Views
    Dan RathbunD
    I posted a blurp at the bottom of the API page: @dan said: Model.add_note returns a Sketchup::Text object associated with the View (has no point, leader or arrow.) [ie, there is no such object class as Note or Sketchup::Note.] Bug: (on PC as of v7.1,) The note (Text object,) will NOT be displayed if there are no other DrawingElements to render. A note added to an empty model will not be displayed until some element is added to the model. If all other DrawingElements execpt the note are deleted, the note will NOT be displayed (but is still in the Entities collection.) So modify the previous example: mynote = model.add_note "test", 0.1, 0.1 ... later in the code, delete the Sketchup::Text object referenced by mynote mynote.erase! or Sketchup.active_model.entities.erase_entities( mynote )
  • Definition Observer

    6
    0 Votes
    6 Posts
    515 Views
    K
    Thanks TIG. TT - I revisited your observers chart page after posting the initial message. Definitely very helpful. Thanks for maintaining it. -- Karen
  • Sketchup and Ruby

    3
    0 Votes
    3 Posts
    541 Views
    A
    Thank you very much for your reply. Unfortunately, I do not have a lot of experience with this kind of stuff so I might need some more guidance
  • Enums's index of an inputbox return

    4
    0 Votes
    4 Posts
    304 Views
    S
    all good now. I'll download the ruby book. Thanks dan.
  • Problem with texture coordinates

    3
    0 Votes
    3 Posts
    281 Views
    A
    Thanks! I found the essential step in your code ( TT::Face.corners( e )). It seems to work for me just fine when I change the order of the points to (the array c contains always exactly 4 points in the same order). pt_array[0] = c[0] pt_array[1] = Geom;;Point3d.new(0,0,0) pt_array[2] = c[1] pt_array[3] = Geom;;Point3d.new(1,0,0) pt_array[4] = c[2] pt_array[5] = Geom;;Point3d.new(1,1,0) pt_array[6] = c[3] pt_array[7] = Geom;;Point3d.new(0,1,0)
  • Getting Started with C++ and Sketchup

    3
    0 Votes
    3 Posts
    3k Views
    S
    Thanks. Now I know where to start.
  • SF Bay Area SketchUp meeting, 4/6

    2
    0 Votes
    2 Posts
    225 Views
    Chris FullmerC
    I'll be there. Its a little over an hour away for me, but I think it will be worth it. And its always fun to meet up with other SU users and talk about SU. It'll be good to see you again Rich, Chris
  • Component definition name

    3
    0 Votes
    3 Posts
    276 Views
    C
    Works great, thanks.
  • Integer vs string test time

    3
    0 Votes
    3 Posts
    202 Views
    honoluludesktopH
    Thanks, I will have to remember how to do that:)
  • Deleting a text

    3
    0 Votes
    3 Posts
    589 Views
    K
    oh, ok, great. thank you!
  • Plane from current view

    5
    0 Votes
    5 Posts
    488 Views
    M
    I have a similar workflow to what your describing but I use photo match and no ruby scripts. Set the view you want, save it at the screen resolution, edit it, then start a Photo Match session using the new image. Everything should line up perfectly as long as nothing has changed. Finally, just project the photo onto the elements of the model using the option on the Photo Match Dialog.
  • Taking a model to particular coordinates

    44
    0 Votes
    44 Posts
    2k Views
    TIGT
    Thanks Dan. As explained my example is just an example - you need to tailor it to you needs so 'f' >>> 'machine' with the .3ds added etc... In you example it much more difficult to read than mine. Your 'processing' is inside the if...end test when rotation is set, BUT my way will work with less likelihood of massing up - you simply gather the 4 lines of data as I show and use the references you set from them to do your processing for each 'machine'...
  • [code] reading a CSV file

    5
    0 Votes
    5 Posts
    3k Views
    Dan RathbunD
    @zps222 said: Hi, Dan, I simply paste "module MyTopLevelNamespace" in to Ruby console window of SU, but the error comes. So why? A module definition is a block statement. It's meant to be read by the interpreter. The console is a line evaluation function. You CAN make a module at the console by putting it all on 1 line, like: module Zps222; def say_hello(); puts "Hello!"; end; end YOU are supposed to choose YOUR OWNidentifier for a toplevel module name (namespace.) Replace "MyTopLevelNamespace" with a unique name that YOU decide. (You can use Zps222, or whatever you want, as long as it is unique for YOU, and noone else will use it.) Also "MyPlugin", you change it to whatever name you want your plugin to be. @zps222 said: By the way, can I use eclipse to run your code? Yes. This code is not Sketchup specific. It's just plain old standard Ruby.
  • Getting info from a text file

    5
    0 Votes
    5 Posts
    420 Views
    Dan RathbunD
    By the way... if YOU are creating the files.. why not simplify things and write out CSV records, where each line is: "string tag",x,y,rot We have a topic on reading CSV text files: [code] reading a CSV file EDIT: Oh you are using MatLab written files, as in this post http://forums.sketchucation.com/viewtopic.php?f=180&t=35961&start=30#p319047
  • Help with using begin, rescue, end

    12
    0 Votes
    12 Posts
    978 Views
    C
    As a good rule of thumb you should only use the begin..rescue..end construct for situations where if an error occurs you need to do something to prevent undesirable side effects. The most common example is with file handling, so say you open a file stream for reading and the program crashes in some way, it's important that you close the file even though it crashes. It is also considered good practice to only suppress the specific type of error that you're having trouble with, as suppressing all error can make debugging very difficult down the road. Also, you're testing using "arc_entities[0]!=nil" when you could test "!arc_entities.empty?" instead, which the code a bit more descriptive, although as already mentioned the .each method was designed for this sort of thing.
  • Flipping texture to opposite face.

    3
    0 Votes
    3 Posts
    221 Views
    J
    This sounds like it could work, as soon as i get chance i'll have a look. Many thanks, much appreciated!
  • Color in add_line?

    3
    0 Votes
    3 Posts
    234 Views
    S
    Found this: Edge color by material http://forums.sketchucation.com/viewtopic.php?f=180&t=35443#p312624 thx
  • Problem adding a face's edges to a layer.

    5
    0 Votes
    5 Posts
    233 Views
    honoluludesktopH
    Tig, Thanks.
  • If else

    15
    0 Votes
    15 Posts
    423 Views
    C
    From the looks of your code you're interested specifically in blocks of four lines, in which case you may gain some mileage out of the array.slice method by doing the following. for i in 0..a.length/4 #there are i blocks of four lines machine,x,y,rot = a.slice(i*4,4) #more code end

Advertisement