Mac User? | Join the Rayscaper Beta for Mac Learn More

Subcategories

  • No decscription available

    20 Topics
    462 Posts
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • Edges, angles on rectangle triangle

    8
    0 Votes
    8 Posts
    1k Views
    C
    Angles are only defined between two vectors, so finding the angle between a vector and a plane can vary depending on which vector in the plane you're interested in. Most of the time, the vector you're interested in is the angle between the vector and it's projection into the plane which can be calculated using the face.plane method and the Array.project_to_plane method. The only trick here is that vectors are not points, so you would have to either pick a point in the plane, then transform it by your vector or translating the plane to the origin and simply calling the vector3d.to_a method. As it turns out, the second method is much simpler since given a plane of of the form [x,y,z,c] then translating it to the origin is as easy as changing it to [x,y,z,0]. Here is the code def angle_between_vector_and_projection(vector,face) plane = face.plane plane[3] = 0 projection = Geom;;Vector3d.new(vector.to_a.project_to_plane(plane)) return vector.angle_between(projection) end
  • Commit working like undo command

    4
    0 Votes
    4 Posts
    427 Views
    thomthomT
    Note that start_operation cannot be nested. Doing a new start_operation after another will commit the first.
  • Get mouse x,y,z location other an with an Inputpoint?

    20
    0 Votes
    20 Posts
    2k Views
    Dan RathbunD
    @chris fullmer said: Well there you have it! Glad you can test if they have Hide Rest of Model on or off. Just be aware that Scene (Pages) can also have their own RendingOptions hash instance.
  • Few Quick Question for Tool

    4
    0 Votes
    4 Posts
    429 Views
    Dan RathbunD
    @kdasilva said: 2) ... How would you recommend saving the variables that keep track of the various inputs my users put in if they want to re-open Sketchup. If the variables are specific to a certain model.. then attributes attached to the model. If they are general to a plugin and will be used with more than one model, then look at Sketchup.read_default and Sketchup.write_default methods. (It's best to convert all data to strings that will be written into the Windows Registry.) Or you can use a Settings Hash convert it to a string with .inspect() and write it out to a file. An easy way is to use Marshal.dump() and Marshal.load() (but there are versioning issues.) It's not that hard to open a File object and use it's write() or puts() method to send the string to the file. That way you won't have marshaling version isssues, and as you need to open the file IO object in both cases, it's not much difference, either way. @kdasilva said: I can store variable information with attributes for entities...but if i wanted to say have arrays that hold different community visions for the model, I don't think I can assign attributes to the model can I? Any Entity subclass inherits the attribute methods. And also they are defined for Sketchup::Model class. So for instance you can attach attributes to a Layer or a (Scene) Page because they are Entity subclasses (not just to the Drawingelement subclasses.)
  • Replace components

    5
    0 Votes
    5 Posts
    836 Views
    liquid98L
    Hi Tig, Thanks I'll do some more study until I get what you suggested and come back here
  • How to identify buildings in Sketchup using ruby?

    2
    0 Votes
    2 Posts
    269 Views
    TIGT
    If you make them components you can find them by name, or attributes you might attached to the definition or instances etc... Using >=6 connected faces [as a 'solid'] could return almost anything from a box of paper-clips, through a TV set or Bed to a 20 storey office building ? Please be a bit more explicit with what is is you are trying to do...
  • Note to self: Array.to_a returns self

    7
    0 Votes
    7 Posts
    543 Views
    AdamBA
    @dan rathbun said: @tig said: a1=[1,2,3] both a2=a1 ### makes a new reference to the same array, 'a1' a2=a1.to_a ### makes 'a1' into an array [which it is already!] and then makes a new reference to the same array, 'a1' !! will still refer to a1, so consequently changing a2 changes a1 too ! BUT a2=a1.dup makes a separate copy of a1, as will a2=a1+[] as adding two arrays together produces a new array, even when the second one is empty; and now changing a2 leaves a1 alone To clarify, since "assignment creates references"...: a1=[1,2,3] ### creates a new array object referenced by a1 a2=a1 ### makes a new reference ( a2) to the same array object that a1 is pointing at. a2=a1.to_a ### a1.to_a returns *self* both references are pointing at the same array object, so consequently that object can be changed using either reference a2 or a1. BUT a2=a1.dup ### makes a new array object, (referenced by a2,) that is a copy of the array object that a1 is pointing at. Nice round-up.. But be aware #dup performs a shallow copy. So any proper objects (as opposed to simple numbers) in that array are copied by reference. So: a = [10, 20, [30,31,32]] c = a.dup a[2][0] = 'Tada!' c will print: [10, 20, ["Tada!", 31, 32]]
  • How to draw an edge with an angle and distance

    25
    0 Votes
    25 Posts
    3k Views
    M
    Mission accomplished Thanks to you all Geniuses
  • WebDialog.execute_script on OSX

    2
    0 Votes
    2 Posts
    508 Views
    thomthomT
    I use the jQuery .ready() event that loads when the DOM is ready to make a callback back to Ruby. Then I can 100% sure I can use execute_script. Works on both platforms. No need for sleep or timers. I've made a few notes about WebDialogs: http://forums.sketchucation.com/viewtopic.php?f=180&t=23445
  • I saw plugin for selecting objects with material

    9
    0 Votes
    9 Posts
    736 Views
    K
    @didier bur said: Besides all this, isn't it a built-in function ? This only captures elements in the currently active entities collection. My plugin also searches for that material in any sub-components or groups. EDIT: It also doesn't work on the default material. Karen
  • [Info] Transformation Matrix Link

    3
    0 Votes
    3 Posts
    646 Views
    thomthomT
    Cheers beans! Appreciate it.
  • [Code] Rantexpos

    9
    0 Votes
    9 Posts
    4k Views
    G
    figured it out. i just need to rotate my face/object to be oriented with the axis. then i can hit rantexpos and it aligns them in the other way. thanks again for your help. mo
  • [Code] New Material methods

    13
    0 Votes
    13 Posts
    4k Views
    TIGT
    Here's an update http://forums.sketchucation.com/viewtopic.php?p=293701#p293701 The MAC jar execution issues have been addressed.
  • How to set length units in code

    3
    0 Votes
    3 Posts
    329 Views
    TIGT
    If you are getting the x/y/z values as strings [perhaps from an imported text file] then ` z=z+'.m' 4.5.m ### as a string eval(z) 177.165354330709 ### in inches [SUp's base units and used to position the point]if they are as floats then z=z.m` will work to convert it...
  • [Code]Transformation_Extensions 20110209

    3
    0 Votes
    3 Posts
    2k Views
    TIGT
    I've updated this code as it was well out of date and new versions drifting around on the forums has typos etc - this is the definitive version [as of today at least ]
  • [code] intersect_with example

    6
    0 Votes
    6 Posts
    6k Views
    TIGT
    I suggest you trap for non-groups selection.each { |entity| ### next if not entity.class==Sketchup;;Group ### entity.entities.intersect_with(true, entity.transformation, entity.entities.parent, entity.transformation, true, entity.parent.entities.to_a) } Also shouldn't entity.entities.parent be entity.entities.parent.entities
  • Get Group Owner

    6
    0 Votes
    6 Posts
    583 Views
    thomthomT
    @cleverbeans said: I believe g3.parent.instances[0] gives you the correct group. Not if the group has instances, which it may have after copying a group and not editing it.
  • Google toolbar: get position

    4
    0 Votes
    4 Posts
    438 Views
    Dan RathbunD
    No.. you cannot intercept the call. It is hard-coded into the Sketchup application on the C++ side, not on the Ruby side.
  • Loop.convex? question

    5
    0 Votes
    5 Posts
    579 Views
    DavidBoulderD
    Thanks for the feedback. The data file that is drawing my geometry in the first place already has a smaller list of verticies that is clean. So I guess that is the best option, going back to that, drawing a temporary face to test, and throwing it away. I don't know how much of a performance hit that will be over testing an existing face. But what I can do is pre-test with the existing face, and then only create a temporary face to test on the ones that initially fail. David Below is the code I ended up with. My SketchUp objects are drawn from data in an external file. I could have drawn temporary faces for convex test for every surface but decided to do the initial test off of the existing SketchUp faces, and then do a second test on faces that fail the convex test to confirm that they really are non-convex. This second test goes back to the data file, draws a temporary surface, tests it, and throws it away. The data file is already fee of un-necessary stray points. if @hash['NON_CONVEX_SURFACES'] face = interior_partition_surfaces[index].entity loop = face.outer_loop status = loop.convex? # if face is convex skip over it if status next else # failed first convex test, run second one pointstemp = interior_partition_surfaces[index].model_object_polygon.points model = Sketchup.active_model entities = model.active_entities facetemp = entities.add_face pointstemp loop2 = facetemp.outer_loop status2 = loop2.convex? # erase facetemp facetempall = facetemp.all_connected entities.erase_entities facetempall if status2 # next statement skips the rest of this if face is convex next end end end
  • Face with 0.0 area

    14
    0 Votes
    14 Posts
    1k Views
    TIGT
    I wasn't suggesting you remove a small face just merge its vertices so it vanishes...

Advertisement