sketchucation logo sketchucation
    • Login
    1. Home
    2. hanl000
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    H
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 17
    • Groups 1

    hanl000

    @hanl000

    10
    Reputation
    1
    Profile views
    17
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    hanl000 Unfollow Follow
    registered-users

    Latest posts made by hanl000

    • Removal of internal lines generated from raytest

      Hi,

      I'm currently working on raytest now.
      The main work of this raytest is to generate triangular faces with specific orders of vector and this step is repeated again to get smaller triangles which make higher accuracy.

      I attached a result of the raytest. You can get what I'm saying.

      After making many triangular faces, I was about to merge the internal lines to look at clear face.
      The problem is, there are lines generated on same positions twice by two trials and they are not removed by existing plugins remove internal lines.

      The overlapped lines, I would like to remove these lines on same position with ruby API. How can I do?


      Triangular Faces.skp


      1.png


      2.png

      posted in Developers' Forum
      H
      hanl000
    • RE: Selection error?? with Ruby API

      Thank you for all kind replies. All my problems are solved except one :

      is there a pattern which determines the order of elements in array? or are they designated randomly in array? If there is a pattern, It will be much easier to control objects

      posted in Developers' Forum
      H
      hanl000
    • Selection error?? with Ruby API

      Hi.

      I was working on 'Selection' with Ruby API and have a problem with it.

      
      entities=Sketchup.active_model.active_entities
      selection = Sketchup.active_model.selection
      a = entities.grep(Sketchup;;Group).each{|e|selection.add e if e.name.include?('aaa')}
      
      

      This is the code selects groups of which name has 'aaa' and it looked like all 'aaa' were selected well.

      The problem was the array 'a' contained other groups together not only 'aaa'.

      Once I tried to do next work(ex : a.hidden = true), other unnecessary groups were worked together.

      The ruby code editor said
      Done. Ruby says: [#Sketchup::Group:0x00000009e7c468, #Sketchup::Group:0x00000009e762c0, #Sketchup::Group:0x00000009e65ab0, #Sketchup::Group:0x00000009e5f868, #Sketchup::Group:0x00000009e3f040, #Sketchup::Group:0x00000009e06920, #Sketchup::Group:0x00000009e05368]

      in the array, only three things should have been selected(I put 7 objects in space. the name of 3 of 7 groups was 'aaa' and others had name of 'bbb')

      How can I exactly select only what I want?

      posted in Developers' Forum
      H
      hanl000
    • Separation of code and image display in webdialog

      Hi,

      I'm currently doing work on webdialog and have two problems now
      This is the code I have made

      
      
            unless file_loaded?(__FILE__)
               toolbar = UI;;Toolbar.new "Icons"
               cmd = UI;;Command.new("Create_Box") { icons }
               cmd.small_icon = cmd.large_icon = "icon.png"
               toolbar = toolbar.add_item cmd
               toolbar.show unless toolbar.get_last_state==0
               file_loaded(__FILE__)
            end
      
            def icons
      
               dlg=UI;;WebDialog.new("Icons", false,"WDID",200,300,10,10,true)
      
      	dlg.add_action_callback("Orbit") {|d, p|Sketchup.send_action "selectOrbitTool;"}
      	dlg.add_action_callback("Hide") {|d, p|Sketchup.send_action "editHide;"}
      	dlg.add_action_callback("Unhide") {|d, p|Sketchup.send_action "editUnhide;"}
      	dlg.add_action_callback("Select") {|d, p|Sketchup.send_action "selectSelectionTool;"}
      	dlg.add_action_callback("Hidden") {|d, p|Sketchup.send_action "viewShowHidden;"}
      	dlg.add_action_callback("Undo") {|d, p|Sketchup.send_action "editUndo;"}
      	dlg.add_action_callback("Redo") {|d, p|Sketchup.send_action "editRedo;"}
      	
      
               html = <<-HTML
               <!DOCTYPE html>
               <html>
                  <head>
                     <meta charset="utf-8" />
                     <meta content="IE=edge" http-equiv="X-UA-Compatible" />
      						    <script>
      							function Select() {window.location = "skp;Select";}
      							function Undo() {window.location = "skp;Undo";}
      							function Redo() {window.location = "skp;Redo";}
      							function Orbit() {window.location = "skp;Orbit";}
      							function Hide() {window.location = "skp;Hide";}
      							function Unhide() {window.location = "skp;Unhide";}
      							function Hidden() {window.location = "skp;Hidden";}
      						    </script>
                  </head>
                  <body>
      
      		<table>
                             <td><button onclick="Select();"><img src="Webdialog/images/Select.png"></img></button></td>
                             <td><button onclick="Undo();"><img src="Webdialog/images/Undo.png"></img></button></td>
                             <td><button onclick="Redo();"><img src="Webdialog/images/Redo.png"></img></button></td>	
                             <td><button onclick="Orbit();"><img src="Webdialog/images/Orbit.png"></img></button></td>
                             <td><button onclick="Hide();"><img src="Webdialog/images/Hide.png"></img></button></td>
                             <td><button onclick="Unhide();"><img src="Webdialog/images/Unhide.png"></img></button></td>
                             <td><button onclick="Hidden();"><img src="Webdialog/images/Hidden.png"></img></button></td>
      		</table>
      
      
                     </form>
                  </body>
               </html>
               HTML
      
      
               dlg.set_html(html)
               
               RUBY_PLATFORM =~ /(darwin)/ ? dlg.show_modal() ; dlg.show();
               
            end
      
      
      

      Once I run this code in Sketchup, One icon opens webdialog is seen. The problem is, icons correspond to each basic tool are not displayed. I correctly specified the pathway to the folder where image files are contained. Please have a look at the attached file. This is what I'm seeing now. My expectation was icons are displayed well.

      For better work, I would like to separate HTML code from the whole code. The codes HTML and Ruby API are mixed look messy. In the code, HTML part is written together and I want to substitute 'Sketchup.find_support_file "Pathway1/Pathway2.html'(or other codes can load external html file) for the internal HTML in main code. How can I proceed this work?


      ์บก์ฒ˜.PNG

      posted in Newbie Forum sketchup
      H
      hanl000
    • RE: Requesting idea for creating shapes with webdialog

      @unknownuser said:

      1. It would be far easier to create separate webdialogs for each shape and activate them from a single Toolbar.

      Thank you for kind answer, sdmitch

      Question brings new questions.

      Now, I'm combining separated codes into one ruby file as you said and am looking around existing tools used webdialog.

      https://github.com/joshaxey/Led-Staircase/blob/master/ledstaircase.rb showed me one good example which Id like to indicate(and I saw 'floorgenerator' you created as well!).

      According to your tip, a single toolbar would be created for indicating one webdialog contains several basic tools which can be jump into each other clicking link on the webdialog. It sounded like I have to use like

      ` #Add item
      A = Module::Class.new

      #Make toolbar
      toolbar = toolbar.add_item A.ACommand

      Show toolbar

      toolbar.show`

      Then, this is different with the way which excisting tool used(difference of code structure).

      I have a few basic tools created based on your help. Maybe, it is better to share my works with other users and would like to make a bridge connects these individual tools on one webdialog by using

      <option value='A' #{@B=='A' ? 'selected' : ''} >Option A</option>

      or

      <input type=radio name=rset value="B"> Option B <br>

      or

      <li class="selected"><a href="C" title="Tool1"><span>Tool1</span></a></li> <li><a href="D" title="Tool2"><span>Tool2</span></a></li>

      Everything will be solved if this problem is solved. Please have a look at the attached two files and help me with this problem


      box_webdialog.rb


      sphere_webdialog.rb

      posted in Newbie Forum
      H
      hanl000
    • RE: Requesting idea for creating shapes with webdialog

      Thank you for giving me clear solution!

      And I got two more questions from the solution.

      1. what codes do I have to use to rotate the shape instead of to_l of val.to_l in the solution?
        to_l is the method of numeric class which can convert inches to length and it's not related with rotation of shape. Maybe, another way is used next to val.. I tried to use just '.degrees', but it didn't work

      2. If I make more webdialogs create different shapes, how can I connect the webdialogs with each other? I'd like to try to make a webdialog which something in the webdialog takes me to another page which shows me another inputbox. It is like usual links in usual webpages and id like to add it.

      To start learning HTML alone is so difficult ๐Ÿ˜• it will be really great if you reply to my questions again.

      Happy Easter!

      posted in Newbie Forum
      H
      hanl000
    • Requesting idea for creating shapes with webdialog

      Hi,

      I am trying to create various shapes(2D, 3D both) with webdialog, not inputbox. Im already familiar with the way creates shapes with inputbox and It was a bit easy to learn. Determining variables(with @) -> drawing shape(with add_face, add_line etc.) -> coordinate(Geom::Transformation) are all steps i have done for creating shapes with inputbox.
      On the other hand, Webdialog,,,, looked unfamilir. To say exactly, Im not good at HTML and Javascript yet. Now, Im looking for the way how I can draw various shapes in Sketchup with Ruby API and Webdialog. Could you please give me advice or help? Your reply will encourage me to study Ruby API hard.
      Again, What I want to know is to make a webdialog can create shapes with variables for length(if the shape is box, and it would be radius or diameter if the shape is sphere), coordinate. Im sharing an example I tried. Id like to apply this code to Webdialog.

      toolbar = UI;;Toolbar.new "Box"
       
       cmd = UI;;Command.new("Create_Box") { box }
       cmd.small_icon = cmd.large_icon = "box.png"
       toolbar = toolbar.add_item cmd
       toolbar.show
      
      def box
      model = Sketchup.active_model
      entities = model.entities
      
      @Length = 0.mm unless @Length
      @Width = 0.mm unless @Width
      @Height = 0.mm unless @Height
      @X = 0.mm unless @X
      @Y = 0.mm unless @Y
      @Z = 0.mm unless @Z
      
      results = inputbox(['Length', 'Width', 'Height', 'X', 'Y', 'Z'], [@Length, @Width, @Height, @X, @Y, @Z], 'Box')
      return nil unless results
      @Length, @Width, @Height, @X, @Y, @Z = results
      
      #Points
      p1 = [0, 0, 0]
      p2 = [@Length, 0, 0]
      p3 = [@Length, @Width, 0]
      p4 = [0, @Width, 0]
      
      group=entities.add_group
      entities=group.entities
      face = entities.add_face(p1, p2, p3, p4)
      face.pushpull @Height
      
      pos = Geom;;Transformation.new([@X, @Y, @Z])
      group.transform! (pos)
      
      end
      
      posted in Newbie Forum sketchup
      H
      hanl000
    • RE: Painting face on cross section

      There were many comments, but no useful comments to solve the problem.

      I've just found out 'Makeface'(by Todd Burch' on Smustard's homepage. It recognizes the closed area even if its not completely closed. I removed all the faces and used 'Makce face'. Finally, The problem was solved ๐Ÿ˜„

      posted in Newbie Forum
      H
      hanl000
    • RE: Painting face on cross section

      Thank you for the reply

      I attached one .skp file which is a result of 'intersect face with model' and three pictures represents what the problem is. I wanted to paint one face one color but an undesired face is painted too. It means, some of faces are not closed individually after intersecting face with the objects, and act like one face. Apparently, the result of cutting plan is many overlapped faces and each face is closed, but it wasn't. other faces also reacted to clicking a mouse


      2D plan_.skp


      3d.png


      problem2.png


      problem3.png

      posted in Newbie Forum
      H
      hanl000
    • RE: Code correction

      Thank you for giving me advices. The problem has been partly fixed by myself. Maybe, I have to pay attention to studying ruby more

      posted in Developers' Forum
      H
      hanl000