sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Updating sketchup broke my (very simple) extension

    Scheduled Pinned Locked Moved Plugins
    13 Posts 3 Posters 1.1k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thomthomT Offline
      thomthom
      last edited by

      When posting longer snippets like that it's best to wrap it in a Code tab to you preserve whitespace. Or just upload the .rb file.

      Will have a look at it later today.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • J Offline
        jackjack1234
        last edited by

        My mistake. I will do that next time.

        Thanks for taking a look. I'm hoping this is simple solution...

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          @jackjack1234 said:

          I tried to today and I noticed that when I use transparency it now shows me the inside of each box and this means I can’t see any other boxes beyond the first layer. As best I can tell the default color is being applied to every ‘inner’ surface in each box, which causes my extension to be useless.

          Not sure what you are describing or what you are expecting. Can you post a screenshot?
          In SU, if you paint a transparent material to a face and the other side of the face has the default material, then the other side should take on the appearance of the transparent material.
          This has not changed in SU 7.1

          Could it be that you need to adjust the Transparency quality of the Style you're using?

          I don't see anything about your code that I can relate to any of what you describe.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • J Offline
            jackjack1234
            last edited by

            Sure I can show you what I mean. I found an old laptop with 7.0 still on it. The two figures that follow are from the side and from above.

            Image

            I used the exact same script/data in both shots, so the only difference is that the new one is made with 7.1 vs 7.0. If you want to see for yourself what I think is happening try this in sketchup:
            • Draw a square
            • Paint the surface red
            • Pull it up
            • Delete a side and notice the color inside is now grey! That’s the grey I’m seeing in the second ‘bad’ image
            • In the old version the color inside would be red! I think that is what’s causing all of this. I’m just not sure how to control the inside surface color in my script (as you can probably tell, I’m not the best programmer in the world).
            Does that clarify my problem for you?

            (Also I tried updating my graphics drivers but that didn’t change anything… worth a shot though)

            Since I have this laptop working now, I’m okay for the moment. But I’d rather fix this issue since it seems like it should be simple… Any ideas?

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              You could try doing it a little differently...
              Make a new color - color=[r,g,b]
              Then make a material=model.materials.add("newMaterial")
              Then set its color material.color=color
              Then give that material some transparency - material.alpha=0.5
              THEN apply that material to the face.material=material AND then face.back_material=material
              ?

              TIG

              1 Reply Last reply Reply Quote 0
              • J Offline
                jackjack1234
                last edited by

                Thanks! You just solved my problem! (I didn’t copy that exactly, I actually just added in the face.back_material = [r, g, b] and defined before doing the push.pull and that solved everything (odd that it worked in 7.0).

                I will work on doing it a bit more elegantly with defining materials and just calling for them because that does sound like a much better solution.

                While you are solving all my problems, here is another question. I’ve always wanted to import a very large set of boxes (voxels, whatever you want to call them) using this technique. But any time I try it with more than say 15,000 using the code I gave above my computer just sits there for hours appearing like it’s doing nothing so I cancel the construction.

                I asked this along time ago on this forum and someone said that it was because each time I did a push.pull action sketchup would check with EVERY piece of the geometry (built that that point) and look for intersections. So as I built more and more boxes, I increased the construction time more and more for each element.

                Do you have any idea if there is a more efficient way I could do this? (or a way to disable that check). Maybe building all the faces at the same time and doing some sort of single ‘group’ push pull? Any thoughts?

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  The more geometry is in the context you add to the more time SU will spend when you add new geometry.
                  What you could do, is make a voxel component. Then just add component instances and apply the material to the component instance. That way there are less entities in the context you add to - and you should also see a decrease in file size.

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Also, look into model.start_operation. Make not of the second argument it accepts - which will disable the UI until you call model.commit_operation.
                    Wraps the whole thing into one undo-able operation and increases the speed.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      jackjack1234
                      last edited by

                      That makes a lot of sense. I guess the real problem is I’m not very experienced with components.
                      Would this work:
                      At the start of the script create a few components representing every possible color element (so 5 colors = 5 components). Then as the script goes and reads from my file it goes through each ‘v’ value it assess it and places the correct colored component in that location (based on the x, y, z).
                      If that would work, do you know any simple tutorials that do this I could use to make this from? (I tend to learn best be either reverse engineering or altering a similar example). Like I said before, I’m still a pretty green programmer, but so far this has been very helpful.
                      I think if I can figure out how to save a component in ruby and later call and place a component I should be able to get this to work.

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        You only need to create one component definition. You can apply different materials to each component instance. When you apply materials to component instances and groups the faces inside with default material will inherit the group/instance's material.

                        That's what makes components so great. You can model a car - do all the detailing, add material to the wheels windows etc, but leave the body with default material. So you can then place lots of instance with different materials.

                        something like:

                        ` model.start_operation('Voxel Thingymajiggy', true) # wrap everything in one operation and disable the UI

                        voxel_def = model.definitions.add("Voxel") # create new definition
                        voxel_def.entities.add_face(...) # build the voxel here

                        <loop> read file

                        calculate a transformation to place the instance

                        voxel = model.entities.add_instance(voxel_def, transformation)
                        voxel.material = myPrettyMaterial

                        </loop>

                        model.commit_operation`

                        Very quick and dirty pseudo-code... 😳

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement