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

    bizello

    @bizello

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

    bizello Unfollow Follow
    registered-users

    Latest posts made by bizello

    • Observers. Can we use them!

      Hello guys,
      I've been reading some posts about Observers. It seems that some do not work right.
      For example SelectionObserver.onSelectionBulkChange, it works in my tests, it identifies when something is selected.
      I also realized that he is always working for alerting when I select something. How to disable Selectionobserver?
      I tried using the remove, but I think did something wrong. It did not work.

      I think it is good to use in my script. It is short showed on next steps:
      (1) I select a face with the right mouse button;
      (2) Choose the action from the context menu and a dialog box, enter data that identify a set of openings (CJAB);
      (3) After another dialog window to enter data that create an opening in the wall;
      All this works already.

      However, for each opening of a set of openings is necessary to perform all the steps.
      I would enter only once with the name of the set of openings. I think do this with SelectionObserver.onSelectionBulkChange.
      I would like to do step 1,2 and 3 only for the first opening of the set.
      After that I am asked if I want to make another opening for that same set.
      If yes, Selectionobserver starts. It keeps the set name to select other face waiting to perform step 3.
      And so is that answer until I do not want to make openings for that set. Then disconnect the Selectionobserver.
      What do you think? Will that work?
      Tell me if I'm on track or whether I should use another observer.
      I've tried to do this but For and While, but there is always the need to monitor user actions to trigger the action of the script.
      Thank you.

      posted in Developers' Forum
      B
      bizello
    • RE: Menu, require and .rb files

      Thanks guys,
      I'll try Ruby modules
      SérgioBizello

      posted in Developers' Forum
      B
      bizello
    • Menu, require and .rb files

      Hi guys,

      I've read some posts about require and rb files.
      So, I would like to know if is possible you have a menu that each sub item call a script or function inside differents .rb files? How to do this?
      I have a main scritp and inside it there are a lot of function that can become smaller functions in separate files used by mora than one script.
      Example: I have two rb files: file1.rb and file2.rb.
      File1.rb do an action that use a function from file2.rb . But file2.rb can work alone too. So, I want to create a menu with two subitem to choose file1.rb or file2.rb.
      This would be amazing! I could separate my functions and use them in several othes scripts, without copy the code lines.
      Thanks

      posted in Developers' Forum
      B
      bizello
    • RE: Edges, angles on rectangle triangle

      My script must enter an opening in a wall orthogonal or tilted.
      The calculations for horizontal and vertical walls are easier, but the script must also include sloped walls at any angle.
      The walls of the room must be obtained from an extruded face on the positive Z axis on the xy plane.
      You must select the face that will open like you're inside the room and facing the wall.
      Click the right button and select the action from the context menu.
      A dialog box opens and asks for the parameters of opening: width, height, sill, position (center, left or right) and distance from the corner
      in accordance with the position.
      Then they get the calculations:
      Checks whether element has selected and if it is a face (rule: not possible to make openings in floor or ceiling);
      Get the edges connected to that face and separates that are built in Z direction (equal xy coordinates) representing the wall height;
      According to the normal of the face, check what is the left edge, base to build on opening;
      Creates the vector with p1.vetor_to p2, between the left edge starting point and right edge, adding the Z coordinate value of the sill;
      This vector is baseline for the construction of the opening. With point.offset (vector distance) you can calculate the points
      to create the face, with distances from the corners
      This last action I thought making a very complex way, finding angles and applying Pythagoras, but with some tips and found a little more
      studying the API could do more easily.
      Thanks to everyone who answered this question.

      PS. But I would like to know how the best way to get the edge or face's angle from a axis or plane?

      posted in Developers' Forum
      B
      bizello
    • RE: Commit working like undo command

      Hi Dan,

      Thank you. Its works now.

      I think understand how using commit.
      Thanks to show how you do your messages in a script. I liked.
      I had some asks about send_action and abort but I saw how they works.
      So, I edit this post.
      Thank you Dan.

      SérgioBizello

      posted in Developers' Forum
      B
      bizello
    • Commit working like undo command

      Hi,
      I trying to use commit to do some like "undo" command. I´ve found something in the net and one script worked, but others...
      The code below works, you can activate only a "commit line" and the face is erased like you want, full control.

      
      def desenha1
      modelo = Sketchup.active_model
      entities = modelo.active_entities
      pt = []
      pt[0] = [0,0,0]
      pt[1] = [5,0,0]
      pt[2] = [5,5,0]
      pt[3] = [0,5,0]
      abertura = entities.add_face pt
      end
      
      def desenha2
      modelo = Sketchup.active_model
      entities = modelo.active_entities
      pt = []
      pt[0] = [0,6,0]
      pt[1] = [5,6,0]
      pt[2] = [5,10,0]
      pt[3] = [0,10,0]
      abertura = entities.add_face pt
      end
      
      def desenha3
      modelo = Sketchup.active_model
      entities = modelo.active_entities
      pt = []
      pt[0] = [6,0,0]
      pt[1] = [10,0,0]
      pt[2] = [10,4,0]
      pt[3] = [6,4,0]
      abertura = entities.add_face pt
      end
      
      #Sketchup.active_model.start_operation("Undo")
      desenha1
      #Sketchup.active_model.start_operation("Undo")
      desenha2
      Sketchup.active_model.start_operation("Undo")
      desenha3
      
      resposta = UI.messagebox "Erase face?", MB_YESNO
      
      if resposta == 6 then
      Sketchup.active_model.commit_operation(a)
      else
      UI.messagebox "So stay."
      end
      
      

      But I have a part of the another code that doesn't work, I think you don't need all the code, so I'm sending the part with "commit" don't working, the code below:

      
      model = Sketchup.active_model
      Sketchup.active_model.start_operation("undo")
      entities = model.active_entities
      abertura = entities.add_face ptabs
      rayt=modelo.raytest(ptabs[0], abertura .normal.reverse)
      ptabs_rev=rayt[0]
      espess=ptabs[0].distance(ptabs_rev)
      abertura.pushpull(-espess)
      
      abeyesno = UI.messagebox "A posição da abertura na parede está correta?
      Proceder com o cadastro no Banco de Dados?", MB_YESNO
      
      if abeyesno == 6 then #yes
         cadaberturas(ptabs, espess, cod_arq_atual[0], cod_arq_atual[1], localiza)
        else
         Sketchup.active_model.commit_operation(abertura)
      end
      
      

      I dont' know why the second code doesn't work. I can't see what is wrong.
      If you help me, very thanks.

      Sérgio.

      PS. I need to answer like I solved the my another topis called "edges, angle and rectangle triangle". I'll to write all the problem and describe my solution.

      posted in Developers' Forum
      B
      bizello
    • Edges, angles on rectangle triangle

      Hi guys,
      I have an diagonal edge on XY plane and Z=0. I got its start and end points. I can calculate its length.
      I want to use Pitágoras to calculate a triangle rectangle.
      I didn´t know to calculate the edge's angle to draw the others sides.
      Cay you help me?
      Thanks since now.
      Sérgio

      posted in Developers' Forum
      B
      bizello
    • RE: WxFormBuilder

      Hi guys,

      Dan, very thanks for the link. The PDF file is excelent. Show how to do, step by step.
      I did my first Webdialog works. Very simple, but works.
      Thanks to thomthom again (is not first time he help me) by the "Lost Manual".
      Course I'll have to learn JS.
      Now... back to work...
      Thank you a lot.

      posted in Developers' Forum
      B
      bizello
    • RE: WxFormBuilder

      Hi Dan,
      Yes, wx is required and this is write at code's beggining. May be a problem the user needs installing it before.
      Other ask, wxFormBuilder shows code in C++, Python and XRC. Is it works in ruby? Sorry this ask, but I'm a designer that wants programming.
      Another thing... wx creates very rows of code. Is possible have a .rb file with only the dialog's code? How can I call a function inside a file from other file? For example: I have functions inside a func.rb file, wich they are called and used by the main routine inside a main.rb file. Is it possible?
      As honoluludesktop, I would like to see a plugin made with UI::Webdialog. I've tried to use it but I didn't do work.
      One example with an elaborated dialog window (radio, pulldow box, text, etc) and how send data to plugin's code, could be very good to learn.
      Thanks for help.

      posted in Developers' Forum
      B
      bizello
    • WxFormBuilder

      Hi guys,
      I need to build a interface for a sketchup plugin.
      This interface has several data inputs like checkbox, radio, text and dropdown list. Sure, there is a OK button to send data to ruby code for processing. There is a cancel button too.
      I downloaded wxFormBuilder wich you can build you form too easy.
      The question: is possible using a wxFormBuilder form with ruby and Sketchup API? If yes, how?
      Building interfaces have being a problem to me. I can't do this. The dialogs don't close, I don't know how to send data and more and more. May be this is my limit? I don't know.
      I needed to do the sketchup to work with Sqlite3. A friend of mine have teached me about data bases. Fine, that's it. It's working.
      Someone can teach me about build interfaces for Sketchup plugins.
      My work is slow becouse I can't solve this interface problem. This is the big problem, in this time.
      Thanks for help.
      Bizlo

      posted in Developers' Forum
      B
      bizello