sketchucation logo sketchucation
    • Login
    1. Home
    2. draftomatic
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    D
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 25
    • Posts 116
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: How to add entities to a nested group?

      TIG, I really appreciate your help, but I still can't see that I'm doing anything wrong.

      I've made a small example script that emulates my bug. Could you take a look please please? πŸ˜ƒ


      test_group_bug.rb

      posted in Developers' Forum
      D
      draftomatic
    • RE: How to add entities to a nested group?

      @tig said:

      I must assume faceEntities is in the same context as the rest.
      But in newGroupGroup = rootGroup.entities().add_group(groupGroup, faceGroup)
      where did groupGroup suddenly come from ? It's not referred to in your example code...
      and IT must be inside the rootGroup.entities - BUT where'd it come from...
      THEN you explode this probbaly non-existent thing == Bugsplat ???

      faceEntities is under model.entities. rootGroup is under model.entities. groupGroup is already under rootGroup (look at the screenshots!). In fact, I created groupGroup with rootGroup.entities.add_group() (I'm 100% sure that groupGroup is correct; I can even find it by searching rootGroup.entities.each())

      @tig said:

      You seem to have overcomplicated it...

      How?

      @tig said:

      Also simply saying group2=group1 is changing a reference - it doesn't transfer 'properties' or 'attributes' - so you need to get the original group2 name and give that to the group2, and the same with layers, materials etc etc...

      I AM doing this. Look at the comments in the example code. The only purpose of groupGroup = newGroupGroup is to keep my variable names, since in the real code these are instance variables.

      @tig said:

      As I said tgroup=ents.add_group(extggroup,facebits)
      'remember' extggroup details first, then
      extggroup.explode
      you have now got the entities that were in 'extggroup' AND 'facebits' inside the same group...
      Now re-refer to tgroup as extggroup and add the 'remembered' extggroup details to []what is now 'called' extggroup ...

      Why do I have to store these properties? Consider this:
      ` newGroupGroup = rootGroup.entities().add_group(groupGroup, faceGroup)

      Copy properties of groupGroup to newGroupGroup here...

      groupGroup.explode()
      groupGroup = newGroupGroup`

      I don't see anything wrong with copying the properties directly before I explode groupGroup. The properties are going from groupGroup to newGroupGroup, so at one point they will have identical properties. Then I explode groupGroup. Seems okay to me...

      posted in Developers' Forum
      D
      draftomatic
    • RE: How to add entities to a nested group?

      @tig said:

      You have a group and faces that you want to transfer into the group.
      Make a new_group containing the group AND the faces.
      Now get all of the properties of the group - name/description/layer/material etc etc
      Repeat those on the new_group.
      Explode the group inside the new_group.
      For all intents and purposes 'new_group' IS 'group' AND it now contains the faces and its previous geometry/entities at the same context level inside it...

      I'm sorry, but isn't that what I'm doing? I practically copied your code... Where am I "moving entities across contexts" ?????

      faceGroup and groupGroup are in rootGroup - i.e., "same context." Then I create a newGroupGroup, containing faceGroup and groupGroup. I transfer properties of groupGroup to newGroupGroup, then explode groupGroup, and set groupGroup = newGroupGroup. Am I crazy or is this exactly what you're describing?

      Also, I don't have multiple faces. I have a single face, and I want these entities grouped together, then placed under model.entities -> rootGroup -> groupGroup.

      EDIT: "newRootGroup" -> "newGroupGroup" in 2nd paragraph...

      posted in Developers' Forum
      D
      draftomatic
    • RE: How to add entities to a nested group?

      This is only working for me to get the faceGroup nested one level deep from model.entities. After that, I get weird results. There exists rootGroup (under model.entities), which contains groupGroup, and I have a face, which should be grouped with its edges and placed inside of groupGroup:
      ` # Make an array of the entities:
      faceEntities = face.edges()
      faceEntities.push(face)

        # Get faceGroup inside of rootGroup:
        faceGroup = @model.entities().add_group(faceEntities)
        newRootGroup = @model.entities().add_group(rootGroup, faceGroup)
        # Copy properties of rootGroup to newRootGroup here...
        rootGroup.explode()
        rootGroup = newRootGroup
      
        # Things seem to work up until here...
        # Now nest it one level deeper:
        newGroupGroup = rootGroup.entities().add_group(groupGroup, faceGroup)
        # Copy properties of groupGroup to newGroupGroup here...
        groupGroup.explode()
        groupGroup = newGroupGroup`
      

      This line: newGroupGroup = rootGroup.entities().add_group(groupGroup, faceGroup) seems to copy my face/edges geometry and creates a new group... also, this crashes the program when I try to explode groupGroup (last line). What's going on?

      After creating faceGroup under model.entities:
      Group Bug before.JPG
      Right before I explode groupGroup:
      Group Bug after.JPG

      posted in Developers' Forum
      D
      draftomatic
    • RE: Plugin w/o script in Plugins folder???

      @thomthom said:

      What plugins?
      Possibly, they've misplaced themselves in the Tools folder. (which is meant to be only Google's tools)

      The plugin was LightUp DEMO. And yea, I just checked... they put their stuff in Tools. πŸ˜ƒ

      posted in Developers' Forum
      D
      draftomatic
    • Plugin w/o script in Plugins folder???

      I've seen commercial SketchUp plugins that work (they even get registered as extensions in SU), but there are no scripts for that plugin within the "Google SketchUp 8/Plugins/" folder...

      How do they do this?

      posted in Developers' Forum
      D
      draftomatic
    • RE: How to add entities to a nested group?

      TIG, can you define "context?" Do you mean parent group?

      I want to nest this "faceGroup" 2 levels deep from model.entities... Does that mean I first have to do your trick to put it in level1group, then again to put it in level2group? This seems ridiculous! What if I wanted to nest faceGroup arbitrarily deep in a dynamic tree of groups? I'd have to write a recursive algorithm that copies all the group information over and over and over... All I'm really doing is changing faceGroup's parent group, right?

      Also... the face entities are both under model.entities, it's just that level2group is under level1group, which is under model.entities...

      posted in Developers' Forum
      D
      draftomatic
    • RE: How to add entities to a nested group?

      @thomthom said:

      This face, are you creating it at some earlier point in your code?

      No, it's an existing face in the model.

      posted in Developers' Forum
      D
      draftomatic
    • How to add entities to a nested group?

      I want to have an Entities object which contains a face and its edges, and I want to group these entities, then add them to a different existing group which is nested 2 levels deep from Sketchup.active_model.entities. I tried this:
      # I already have the face (face), and the nested group (level2group) I want to add it to... ents = face.edges() ents.push(face) faceGroup = level2group.entities().add_group(ents)

      This doesn't work... faceGroup ends up without a parent, it seems. I attached a picture of what it looks like in the Outliner.

      also... the groups are locked, but should that make a difference? I tried unlocking them first and got the same result.


      The problem

      posted in Developers' Forum
      D
      draftomatic
    • Does SketchUp delete empty groups?

      I'm trying to have some empty groups in my model, which could hang around for a while, even across separate sessions of SU. They are locked. However, when I draw anything, it deletes my groups! Rude...

      i.e.:
      myGroup = Sketchup.active_model.entities.add_group myGroup.name = "My Group" myGroup.locked = true

      Then use the Rectangle tool to draw a rectangle, and watch the new group disappear from the Outliner.

      Is there a way around this?

      posted in Developers' Forum
      D
      draftomatic
    • RE: WebDialog - execute_script outside of add_action_callback?

      @thomthom said:

      From this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=23445

      Thanks a ton, thomthom - that thread just cured about 16 of my headaches (99 more to go!). The API documentation on WebDialogs is way too minimal...

      posted in Developers' Forum
      D
      draftomatic
    • RE: WebDialog - execute_script outside of add_action_callback?

      @thomthom said:

      @draftomatic said:

      Is using execute_script outside of an add_action_callback block allowed?

      In which case that is your problem, the webdialog has not manage to initiate yet.
      What I do is create a load callback, then in the javascript hook into the event that triggers when the DOM has loaded and send a message back to Ruby for the load callback. Then I do the Ruby initiation stuff from there.

      Cool thanks, I'll try that.

      Follow-up question: Does WebDialog DOM stay loaded when you use WebDialog.close() and then WebDialog.show()? Or do I need to wait again?

      posted in Developers' Forum
      D
      draftomatic
    • WebDialog - execute_script outside of add_action_callback?

      Is using execute_script outside of an add_action_callback block allowed?

      My code isn't working unless I do this, but if that's the case, then how do I send information to JavaScript without JavaScript asking for it?

      i.e.
      This doesn't work:

      
      webDiag = UI;;WebDialog.new(...)
      webDiag.set_html(...)
      webDiag.show()
      
      webDiag.execute_script("document.getElementById('myID').value = 'abc'")
      
      

      But this does:

      
      webDiag = UI;;WebDialog.new(...)
      webDiag.set_html(...)
      webDiag.add_action_callback('update') { |web_dialog, params|
        web_dialog.execute_script("document.getElementById('myID').value = 'abc'")
      }
      webDiag.show()
      # Then JavaScript sends "update" back to Ruby...
      
      
      posted in Developers' Forum
      D
      draftomatic
    • What DHTML does WebDialog support?

      What versions of HTML/JavaScript/CSS does the WebDialog class support? Is this listed anywhere? I'd like to know specific tags if possible.... in particular, what about the <frameset> tag?

      posted in Developers' Forum
      D
      draftomatic
    • RE: Simple example not working...

      @jim said:

      "Test" is about the worst name you choose for an identifier.

      Ah now it works. Thanks!

      posted in Newbie Forum
      D
      draftomatic
    • Simple example not working...

      I wrote a quick test class just to check something, but I can't figure out why it isn't working:

      require 'sketchup.rb'
      
      class Test < Sketchup;;AppObserver
        def onNewModel(model)
          UI.messagebox("new model!")
        end
      end
      
      t = Test.new
      Sketchup.add_observer(t)
      

      That gives an error when SketchUp loads:
      Error Loading File test.rb
      Test is not a class

      Anyone?

      posted in Newbie Forum sketchup
      D
      draftomatic
    • 1 / 1