sketchucation logo sketchucation
    • Login
    1. Home
    2. maricanis
    3. Posts
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 14
    • Posts 43
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Width problems with select option in WebDialog

      I would avoid any spaces based alignment, because GUI is translated in few languages, and with spaces I can't predict how long it will be in each language.

      For styling classes are much better solution, but in example I just wanted to point out that I need some predefined width.

      Thanks Dan, I didn't know that inline styles render controls differently than is style is defined in CSS class.
      I'm also interested if it kills META for the whole document or just that one control.

      Thom, I've just read your link Doctype---Quirks-vs-Standard-vs-Superstandard and it made me completely puzzled. When I include:
      <meta http-equiv="X-UA-Compatible" content="IE=8"/>
      it renders my GUI completely different then before, and all dialog alignments look crazy.
      Must look little bit more into this rendering mode thing.

      Is it conflicting in any way with meta tag Dan proposed in one post?
      <meta http-equiv="MSThemeCompatible" content="Yes">

      posted in Developers' Forum
      M
      maricanis
    • RE: Width problems with select option in WebDialog

      Hi Aerilius,

      My code works correctly, selection and everything related to it, only the appearance is not good.
      I tried changing default browser, but if I understood Thom well problem is in embedded IE which is used for WebDialogs internal implementation.

      Anyway, I'll keep it as it is now, since no better solution found.

      Thanks again.

      posted in Developers' Forum
      M
      maricanis
    • RE: Width problems with select option in WebDialog

      Thanks Thom,

      I'll try to send them bug info, maybe they'll do something this time.

      Any idea how to overcome the problem, maybe to use some custom combo box control or so?

      posted in Developers' Forum
      M
      maricanis
    • Width problems with select option in WebDialog

      Hi,

      I'm trying to make WebDialog with nice layout of elements. As one of elements in the dialog I use html element select.
      Since elements should be aligned well, my select controls are wider then text inside them and when user should select one of options, option drop-down looks narrower than select element.
      HTML file opened as WebDialog

      The same file opened in browser looks as expected- when drop-down is opened all options have the same width and selection control
      HTML file opened in Browser

      Here is simple test code
      file_loaded?(__FILE__) #create and show dialog @wd=UI::WebDialog.new("Selection", false, "",300, 190, 300,300, false ) f= File.join(File.dirname(__FILE__),"selection_example.html") if not File.file?(f) UI.messagebox(text,MB_OK,"Dialog definition file #{f} doesn't exist") else @wd.set_file(f) @wd.set_size(300,200) @wd.show() end

      And html code:
      ` <!DOCTYPE html>
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="MSThemeCompatible" content="Yes">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      </head>

      <body>
      <div class="DL_selection">
      <select style="width:250px" name="season_select" id="season_select">
      <option value="year" id="year_season_select" >year</option>
      <option value="summer" id="summer_season_select">summer</option>
      <option value="autumn" id="autumn_season_select">autumn</option>
      <option value="winter" id="winter_season_select">winter</option>
      <option value="spring" id="spring_season_select">spring</option>
      </select>
      </div>

      </body>
      

      </html>`

      I've tried various styles changes both in HTML file and in external CSS, but nothing solved the problem.

      Have anyone found this problem before? I couldn't find any solution in old forum posts.

      Ideas for solution?

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Minimize WebDialog from code?

      @gábor said:

      You can resize it, you can position it off-screen but I do not know any method for minimizing it unless you somehow manage to trigger a mouse-click on the minimize button.

      Thanks, it seems like good solution for now.
      Resize it to really small value (so only title bar is visible), and then when calculation is finished resize it back to original size.

      Only problem is that if I want to restore original size while calculation is running, minimize/restore button restores to small window size (and not original one).

      Other ideas are welcome too,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • Minimize WebDialog from code?

      Hi,

      Is there some way to minimize/restore WebDialog programmatically from code?

      In my plugin, after user enter all data in the dialog and press Start, model is exported and some simulations are started. I do not close dialog, because it may be needed after calculation is finished, so it would be good that dialog is minimized while simulation is running.

      I haven't found in API appropriate function for that and no info on the forum too.

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Change plugin variables within Undo

      Hi,

      Here is example of code.
      I have global variable @@dl_materials_changed which enables toggling on-off of faces materials in the model.
      Each time user press UI button this function onToggleMaterial is called.

      So with this code Undo correctly switches materials back, but @@dl_materials_changed flag is not changed, so next time I press button in UI it doesn't have correct value.

      def onToggleMaterial()
          Sketchup.active_model.start_operation("toggle materials")
          showFCMaterials()
          Sketchup.active_model.commit_operation()
      end
      
      def showFCMaterials()
          #load all faces in @faces varialbe
          @faces = getFaces(Sketchup.active_model.entities)  
      
          #Set materials if flag is true
          if @@dl_materials_changed
              @faces.each {|face|
                  material_name = face.get_attribute("faceData","material_name","")
                  if material_name != ""
                       face.material = materials[material_name]
                  else
                       face.material = nil
                  end
              }
              @@dl_materials_changed = false
          else
               @faces.each_value {|face|
                  face.material = nil
              }
              @@dl_materials_changed = true
          end
      end
      
      posted in Developers' Forum
      M
      maricanis
    • Change plugin variables within Undo

      Hi,

      In my plugin I define undoable operation with start_operation and commit_operation around my code.
      Operation does next:

      • check some flag value
      • based on flag changes materials of multiple surfaces in the model
      • sets new value to the flag

      If I use undo, after performing operation - materials are changed back correctly, but my internal flag variable is not, so next time I try to run operation staring flag value is wrong.

      Question:
      Is there some way to define which function Sketchup should call when Edit->Undo is clicked?

      I've looked Transaction observers, but it seems like they will trigger for every step of my operation (for each surface's material change), which is not the thing I need.

      I've tried to find similar question on the forum, and also browsed through API documentation, but haven't found solution.

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Detect changes in geometry?

      TIG,
      Interesting idea to put all in temporary group and lock it.
      It seems good idea, but my client've just said that model 'freezing' is not a good option for them.

      However, I've never used start_operation and Undo related features, so this is good opportunity to look them too.

      Thanks,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Detect changes in geometry?

      @thomthom said:

      @maricanis said:

      Calculation doesn't block Sketchup, so user can explore model in the meantime.
      How are you doing this? Ruby C Extension?

      I run some external programs, so I put commands to run in a batch file and run it with UI.openURL(batch_file). It opens black cmd prompt screen, but in general works good. I tried to remove/avoid black screen but not much sucess, so I leave it for now.

      @thomthom said:

      You can use the ToolsObserver to detect when the Move, Rotate and Scale tools has performed an action.

      Yes I saw similar suggestions on forum to track ToolsObserver instead of EntitiesObserver, and just now when I've read again API help pages I see that ToolsObserver.onToolStateChanged can be useful for this.

      Thanks,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • Detect changes in geometry?

      Hi,

      Is there some way to detect when model geometry is changed, but to ignore all other changes in the model (materials, layers etc).
      For example entities adding and deleting can be detected with Sketchup::EntitiesObserver::onElementAddedand Sketchup::EntitiesObserver::onElementRemoved, but these observers won't detect when some of the surfaces in the model is modified (eg. scaled, rotated, moved).
      Sketchup::EntitiesObserver::onElementModified is not good solution because it catches all modifications on element and not only geometry ones.

      Why do I need this?
      In my plugin I calculate some sun-shadow properties related to the model. Calculation doesn't block Sketchup, so user can explore model in the meantime. It takes few minutes to calculate results. When/if geometry is changed, calculations should be repeated. So I want my plugin to know when to repeat calculations, and when to keep existing results.

      Related to this question:
      If not possible to detect geometry-only changes, is there some way to "froze model", so it can't be changed (but can be explored) while in calculation mode?
      Once user exists calculation mode for my plugin, model should be unfrozen and changes possible again.

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • Number of processors

      Hi,

      Is there a way to get number of processors with Ruby in Sketchup.
      I've found on internet solutions like this

      require 'win32ole'
      wmi = WIN32OLE.connect("winmgmts;//")
      num = wmi.ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
      

      problem is when I run this in Sketchup I get error

      - unknown property or method `NumberOfProcessors'
          HRESULT error code;0x80020006
            Unknown name.
      Error; #<WIN32OLERuntimeError; unknown property or method `NumberOfProcessors'
          HRESULT error code;0x80020006
            Unknown name.>
      
      

      I'm using win32ole posted here: [Plugin Library] Win32API and Win32OLE so files

      posted in Developers' Forum
      M
      maricanis
    • RE: Kill external process

      Thanks Dan,

      Your suggestion to write callback that is called from killing object, was very useful idea - and makes nice readable code.

      Much better idea then various signals I planned to use before.

      Thanks again,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Kill external process

      Hi,

      I've implemented killing of external process (which is started by UI.openURL) with next method:
      -call 'tasklist' - to check is process is still running and to get process PID
      -then in plugin Process.kill("KILL",PID)

      This approach works, but I also want to inform object that started external process that process is killed (so some timers are stopped).
      I though to implement that with signals:
      -after process is killed I send signal "USR1" for example
      -and I trap the same signal in class that started process - and then stop timers.

      Problem is that Sketchup doesn't recognize "USR1" signal.

      I've tried in Ruby console:

      
      Signal.list.keys.join ", " 
      TERM, SEGV, KILL, EXIT, INT, FPE, ABRT, ILL
      
      

      But none of these signals are the ones I need, I need some custom user defined signal for my plugin.

      Is the thing I need possible, and how to do it in Ruby/Sketchup?

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: [Plugin] Trace Ruby messages

      Hi,

      I'm using latest version (from may 2011) and noticed strange problem.
      When I have plugin wxSU installed and !trace_console.rb, while Sketchup is running - no problems, and CPU usage is as expected.
      When I try to exit Sketchup,SU window is closed but Sketchup.exe process is not finished, and it uses maximal CPU load (when checked in TaskManager).
      ##########

      If only one of these 2 plugins wxSU and !trace_console.rb is installed Sketchup process is ended without problems.

      It seems that writing to text file is blocked for some reason, and trace file can't be closed.

      I'm using SU 7.1 and 8, on Windows 7.

      Marija

      posted in Plugins
      M
      maricanis
    • RE: Position_material problem

      Hi Thom,

      Here is example and results (I'm obviously doing something wrong, but not sure where the problem is).

      In model I have 2 groups:
      group1 - consisting of 2 subgroups, where one subgroup contains face we analyze in example
      group2 - consisting of some object.

      Here is the code, to get the face I go through hierarchy - but every time it is the same face

      
      face = Sketchup.active_model.entities[1].entities[1].entities[14]
      p1 = face.outer_loop.vertices[0].position
      t1 =Sketchup.active_model.edit_transform
      p1_trans_inv = p1.transform(t1.inverse())
      
      puts "P1 coordinates [#{p1.to_a.join(',')}]"
      puts "Edit_transform [#{t1.to_a.join(',')}]"
      puts "Edit_transform_inverse [#{t1.inverse.to_a.join(',')}]"
      puts "P1_transform_inverse [#{p1_trans_inv.to_a.join(',')}]"
      
      

      Absolute P1 coordinates in SU coordinate system are:[-393.700787401575,196.850393700787,0.0]

      I call this small script for various cases of opened groups inside model and here are results:

      *opened group where face is
      P1 coordinates [-393.700787401575,196.850393700787,0.0]
      Edit_transform [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,-548.031496062992,196.850393700787,0.0,1.0]
      Edit_transform_inverse [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,548.031496062992,-196.850393700787,-0.0,1.0]
      P1_transform_inverse [154.330708661417,0.0,0.0]

      *closed group with face, opened parent group
      P1 coordinates [154.330708661417,0.0,0.0]
      Edit_transform [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,-548.031496062992,196.850393700787,0.0,1.0]
      Edit_transform_inverse [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,548.031496062992,-196.850393700787,-0.0,1.0]
      P1_transform_inverse [702.362204724409,-196.850393700787,0.0]

      *closed group with face, opened parent group, opened other group in the parent
      P1 coordinates [154.330708661417,0.0,0.0]
      Edit_transform [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,-367.646959030915,310.128373863173,80.3149606299213,1.0]
      Edit_transform_inverse [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,367.646959030915,-310.128373863173,-80.3149606299213,1.0]
      P1_transform_inverse [521.977667692332,-310.128373863173,-80.3149606299213]

      *closed group, closed parent group, opened some other group
      P1 coordinates [154.330708661417,0.0,0.0]
      Edit_transform [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,-464.698354923942,49.8468801242114,-1.13686837721616e-013,1.0]
      Edit_transform_inverse [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,464.698354923942,-49.8468801242114,1.13686837721616e-013,1.0]
      P1_transform_inverse [619.029063585359,-49.8468801242114,1.13686837721616e-013]

      *closed all groups
      P1 coordinates [154.330708661417,0.0,0.0]
      Edit_transform [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0]
      Edit_transform_inverse [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0]
      P1_transform_inverse [154.330708661417,0.0,0.0]

      As you can see using inverse edit_transform gives each time different results for 'P1_transform_inverse', depending which group is opened - and my goal is to get in each case the same results (since these should be absolute coordinates)

      Also notice- that when group with face is opened- we get absolute coordinates (and not relative to the group origin), while in all other cases we get relative coordinates for p1.

      So as in previous mail my question is how to get correct absolute coordinates for all other cases (when group with face is closed, and some or no other groups are opened)?

      Thanks for patience,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Position_material problem

      Hi,

      After few days of trying to make my coordinates calculation work correct, I still have no good solution.

      And I've come to problem how to calculate absolute point coordinates, when I have only relative ones. And problem is with various cases when face is in group, or in nested group or outside of group etc...

      Is there some plugin which can from relative coordinates (based on currently opened groups in model), calculate absolute coordinates in SU coordinate system.

      For example to get group origin for various cases I have a face in a group I get group origin as:

      
      group = face.parent.instances[0]
      origin = group.transformation.origin
      
      

      This gives me various results depending whether group is opened or not:

      *group opened - origin is [0,0,0]
      *group closed, but parent group opened - it gives me good absolute values for group origin
      *group closed and parent group closed - origin is [0,0,0]
      *group closed, parent closed, some other group opened - origin is [0,0,0]

      How to get group origin coordinates in cases when I get [0,0,0]?
      In first case model.edit_transform gives me values needed.
      But in other two cases - since edit_transform is not solution.

      Is there some standard way to get absolute coordinates - no meter which group is opened?

      Any idea is welcome,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Kill external process

      Thanks Dan,

      For now plugin is only Windows oriented so these tasklist or tlist would do the job for listing running processes

      posted in Developers' Forum
      M
      maricanis
    • Kill external process

      Hi,

      I'm running some external processes from my plugin.
      Since they can run rather long, I would like to offer a user possibility to abort started external process. Is there some elegant way to do it in SU?

      Only way I've found for now is when user press some button, I call:

      taskkill /f /im my_program.exe
      

      or

      tskill my_program
      

      (since no idea how to get PID of the external process from my Plugin, I use image name or exectuable name).

      BTW: I'm running process with UI.openURL() and batch_file.
      I'm using SU 8 in Windows 7 operating system.

      Thanks in advance,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • RE: Position_material problem

      Thanks for fast answer.

      I've tried straightforward using of this function, but doesn't give expected results.

      I suppose solution would be more complex like:
      *edit_transform before materials are positioned for the first time
      *then when toggling materials on/off again some edit_transform or maybe inverse etc.

      I'll experiment on this, and send some info about my progress in a few days.

      Thanks again,
      Marija

      posted in Developers' Forum
      M
      maricanis
    • 1
    • 2
    • 3
    • 2 / 3