sketchucation logo sketchucation
    • Login
    1. Home
    2. hgroeneveld
    3. Posts
    ℹ️ 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 2
    • Posts 10
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Webdialog visible/open?

      Well, bad news: its snowing outside...no sun for me

      I get the part of making an instance variable in the class ShowDialog.
      But I still cannot reach it in de Observer with the code you gave to me. What is passed to "def initialize(show_dialog)"??? I put a msgbox there, but it never gets triggered... Because I don't understand what is happening in "def initialize(show_dialog)" , I also don't understand the part of "webdialog = @show_dialog_instance.window" in "def onElementAdded(entities, entity)" neither. The code fails after this part... Shouldn't it be something like ShowDialog.my_dialog or something...(also this aint working)???

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Webdialog visible/open?

      Hmmmm. can't get it working right now, hope tomorrow will bring me sunshine. Thnx for your help Thomthom, I will ty to get it working

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Webdialog visible/open?

      Thnx for lookling into it Thomthom!
      You're right for this example: I made some typing mistakes...sorry! πŸ’š

      This is the order of appaerance:

      • In an early stage I call my webdialog by initializing ShowDialog (which contains an info-table). After calling the dialog, I leave it open (or I might close it...whatever), and go on drawing stuff, make some coffee etc. etc.

      • Somewhere later I attach the EntitiesObserver "AddEntities" by code. From this point, when I'm drawing I would like Ruby to know if the webdialog is still open. If open, I would like to refresh the content of the webdialog. But how does Ruby know if the webdialog is still open? I thought by using .visible?. But for using that I need to reach the object webdialog. And I don't know how... 😞

      I don't have a clue how to attach code propperly, but here's the code with minimized abstraction:

      require 'sketchup.rb'
      
      #========================================================================================================================================
      
      class ShowDialog
      	def initialize
      		my_dialog = UI;;WebDialog.new("Information", true, "", 400, 400, 100, 100, true)
      		
      		my_dialog.add_action_callback("get_data") do |web_dialog,action_name|
      			#...some code here...
      		end 
      		
      		html_path = Sketchup.find_support_file "tableHTML.html" ,"Plugins/Toolbar_v2/webdialogs"
      		my_dialog.set_file(html_path)
      		my_dialog.show()
      	end
      end 
      
      #========================================================================================================================================
      
      class AddEntities < Sketchup;;EntitiesObserver
      	def onElementAdded(entities, entity)
      		#...some code here
      		
      		#here I would like to check if the dialog (created earlier..or not) is open/visible
      		#But how do I reach the webdialog? I don't want to create a new one, I would liketo reach the open one...
      		
      	end
      
       end
      
       #========================================================================================================================================
      
      posted in Developers' Forum
      H
      hgroeneveld
    • Webdialog visible/open?

      Probably an easy one; how do I check (while I'm drawing f.e.) whether my dialog is still open/visible or not?
      I've got something like this (concentrate on the bold part):

      class Show Dialog # works great, I can access my dialog
         def initialize
            my_dialog = UI;;WebDialog.new("Information", true, "", 400, 400, 100, 100, true)
            my_dialog.add_action_callback("get_data") do |web_dialog,action_name|
               #......some nice code
            end 
       
            html_path = Sketchup.find_support_file "webdialog.html" ,"Plugins/webdialogs"
            my_dialog.set_file(html_path)
            my_dialog.show()
         end
      end
      

      and an observer where I would like to check if the webdialog is currently open while I'm drawing:

      class addEntities < Sketchup;;EntitiesObserver 
         def onElementAdded(entities, entity)
            #......some nice code (works!)
       
            my_dialog = UI;;WebDialog.new("Information", true, "", 400, 400, 100, 100, true)
            vis = my_dialog.visible?
            UI.messagebox vis # this returns false, even if the dialog is open...
         end
      end
      
      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Intersecting and Attribute inheritance

      TIG! Wonderfull! That's it!!! 😍

      I just tried it in a small example and it worked! It was exactly what I was thinking about but couldnt achieve...

      Now I have to find out how the magic works. Especially the way you loop through faces3 and collect the attributes from faces1 and faces2. There is some new stuff in the code for me (classify_point(pt)?PointInside? Transformation.rotation(vt.position, Z_AXIS, 1.degrees)?).

      Thanks for the great help! πŸ‘ πŸ‘ πŸ‘

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Intersecting and Attribute inheritance

      TIG, thanks for the warning...but I really need to attach information to the level of faces...I think...unless there is a better way to achieve what I need of course! This picture shows 2 groups with each his own information (attributes) attached to plots/zones (faces) and a third group which shows the intersect result I would like to achieve.

      Data I would like to attach to every plot (read: face) is something like owner, plotnumber, address, prize, date of purchase, grounduse etc.
      In that case, showing information by material wouldn't be enough...although it would be nice to make kind of themes like 'most-valuable-plots'(but that will be step 21 or so πŸ˜›).

      http://www.planmaat.nl/images_site/sketchup_intersect.jpg

      I hope this picture will help you to understand the goal I'm trying to achieve.

      BTW, I'm still working on a 'postable' piece of code...

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Intersecting and Attribute inheritance

      Wow...and thanks...again! I was still chewing on your previous post.
      TIG, I think you touched the essence of the problem: yes, I'm talking about attached attributes to the entities in the groups, in particular faces. An attribute could be the owner of a plot(attribute of an entity Face in group1) or whether in a zone it's allowed to develop housing or not(attribute of an entity Face in group2).

      The result could be that Mr. Smith can only develop housing on a part of his plot, because the intersection of the 2 groups will tell us that. (a face in the third group now have the attributes from plot and zone!)

      I'm still trying to understand and testing your previous post... Today I will try to get it to work. Then I will post my code I made so far. Hope it will make it easier to talk about.

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Intersecting and Attribute inheritance

      Wow... I need to get in to this! Looks like it could be the push and direction I asked for. Can't see yet in which way the combination of attributes are passed to the new group, but I will work this out first.
      I'll get back at this after the weekend...

      TIG, thnx again!

      posted in Developers' Forum
      H
      hgroeneveld
    • RE: Intersecting and Attribute inheritance

      Thanx for your reply TIG!

      I saw you already wrote a lot about intersect_with on different forums. Makes you a kind of expert huh πŸ˜‰

      I already achieved what you replied. The result is that I have the intersection lines in a different group (group3). But actually I need faces...
      Probably its possible to add faces to the lines, but how do these faces inherit the attributes from the faces in group1 and group2?

      Should I loop through all the faces in group3 (the new group) and check which attributes they should inherit from group1 and 2 (somehow, I don't know...yet)? Or is there a more obvious, easier and less-time-consuming way to achieve this?

      Any help or push in the right direction is appreciated!

      posted in Developers' Forum
      H
      hgroeneveld
    • Intersecting and Attribute inheritance

      Hi there!

      Please forgive my bad english, I'll try hard to explain my issue. I would like to achieve a very specific goal in SketchUp-Ruby. Assume you have 2 different groups with different 2D-content.

      The first group contains for example plots. Each plot contains information (in attributes) like owner,address, area etc.
      The second group contains zones, for example noisezones, with attributes like development potential.

      My goal is to intersect the 2 groups and put the result in a 3rd group. The 3rd group should inherit the attributes from both groups. This way, you'll have the information like the development potential of Mr. Smith's plot.
      I tried the intersect_with method (worked great with solids, couldn't get it working with flat content) and exploding the groups into a 3rd group. But in no way i could get the attributes from both groups into the 3rd. So I'm pretty stuck right now.

      For this issue I would like some guidance to push me in the right direction. I would be delighted to recieve short examples if possible. Please, can anyone help me?

      posted in Developers' Forum
      H
      hgroeneveld
    • 1 / 1