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

    Topics

    • M

      Detect if cpoint is clicked

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      414 Views
      Dan RathbunD
      @maricanis said: I was concerned what would happen if user select other Scene for example while tool is active, ... I believe the active_view is a singleton object of the model. (there is only one.) The user sees scene pages through the active_view.
    • M

      OnElementAdded inside Group or Component

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      489 Views
      M
      Hi, I've been experimenting on adding/removing EntitiesObservers when groups/components are opened/closed, and I've found difference in behavior in old and new Sketchup versions. When I have few nested groups and I open/close them multiple times (without leaving top parent group): Sketchup 8 and Sketchup 2013 - observers are added/removed as expected and each new entity is detected only once Sketchup 2014 and Sketchup 2015 - it seems like observers aren't removed each time 'onActivePathChanged' is called (although in console is printed that they are removed). When I add new face inside some nested group it is detected multiple times. Number of times EntitiesObserver is called is increased each time I open/close some subgroup. Below it the code which is independent from my plugin and can be simply loaded in Sketchup for testing purposes: module DL;;Daylighting #Attach observers to model, entities and materials class DLAppObserver < Sketchup;;AppObserver def initializeObservers(model) model_observer = DL;;Daylighting;;DLModelObserver.new() model_observer.initializeObservers(model) model.add_observer(model_observer) end def onNewModel(model) initializeObservers(model) end def onOpenModel(model) initializeObservers(model) end end class DLModelObserver < Sketchup;;ModelObserver @@observers = {} @@entitiesObserver = nil def initializeObservers(model) @@entitiesObserver = DL;;Daylighting;;DLEntitiesObserver.new() model.entities.add_observer(@@entitiesObserver) end #When new group is opened remove old observers and add new observer for active_entities def onActivePathChanged(model) puts "active path changed" #remove all previous observers @@observers.each_pair{|entities,observer| begin puts "***entities #{entities} remove observer #{observer}; #{entities.remove_observer(observer)}" rescue Exception => e puts "Can't remove observer",e.message end } @@observers={} #if all groups are closed -> don't add observers if !Sketchup.active_model.active_path return end entitiesObserver = DL;;Daylighting;;DLEntitiesObserver.new() entities = Sketchup.active_model.active_entities puts "***entities #{entities} add observer #{entitiesObserver}" if entities.add_observer(entitiesObserver) @@observers[entities] = entitiesObserver end end end class DLEntitiesObserver < Sketchup;;EntitiesObserver def onElementAdded( ents, new_ent ) #detect only Sketchup;;Face entities if new_ent.class == Sketchup;;Face puts "onElementAdded #{ents}; #{new_ent}" end end end end #DL;;Daylighting To attach these observers to the application just in call in Ruby console app_observer = DL;;Daylighting;;DLAppObserver.new() app_observer.initializeObservers(Sketchup.active_model) Sketchup.add_observer(app_observer) I don't understand what I'm doing wrong, because printed messages in ruby console show that old observer is always removed from entities when Active path is changed, but still new faces are detected multiple times. Once I leave all groups and go back to model (active_path=nil), all observers are like reset and I have only one EntitiesObserver. When I go inside groups and subgroups again, the number of observers increases again. And to repeat, in Sketchup 8 and Sketchup 2013 - this problem doesn't exist. Any suggestion is welcome, because I'm moving in circles with this observers. Thanks in advance, Marija
    • M

      Distinct between entities in instances

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      384 Views
      TIGT
      To recap. Component definitions can have attributes. These apply to the definition and are therefore accessible via definition.get_attribute(...) Component definitions can have entities, These entities can have attributes. These apply to the entities with the definition, and are therefore accessible via some_entity.get_attribute(...) Component instances can have attributes. These apply to the instance and are therefore accessible via instance.get_attribute(...) If you have an attribute set for any entity that is within a definition.entities context, then that attribute is accessible all instance.definition.entities - i.e. it is the same attribute, and therefore if you ' .set_...' it, it affects every instance sharing that definition - just as if you had painted a face 'red' inside the definition you should expect every instance to show that subsequently.
    • M

      Set_position for modal dialog

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      6
      0 Votes
      6 Posts
      429 Views
      tt_suT
      I know that under OSX there are issues if you use the body.load event to modify the webdialog. It appear white until you click in the window - but I've not seen that under Windows. For the OSX issue the solution is to use the event that trigger when the DOM is ready. All though, I use jQuery to take care of cross-compatibility issues.
    • M

      Center Webdialog over Sketchup window

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      406 Views
      A
      You could theoretically read the screen dimensions using JavaScript, divide by two and subtract half of the dialog's width and height (you can read the inner width without window border using JavaScript). This is not recommended. If it is not essential to the functioning of you plugin, think again if you can get along without it. This causes your dialog to launch initially with different dimensions and then "jump". On a multi-monitor setup, you don't know whether the dialog is on the second monitor, and the above formula will give you coordinates for the first monitor. The dialog will jump to the first monitor, if it was launched (by registry preferences) on the second one.
    • M

      Average color pasted instead of texture. Why?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      277 Views
      M
      Thanks Dan, That is exactly what I needed!
    • M

      Width problems with select option in WebDialog

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      23
      0 Votes
      23 Posts
      605 Views
      tt_suT
      @maricanis said: Frankly, no experience and knowledge about document modes, I've just used the default ones till now. Any suggested readings on this? Especially related to embedded vs. browser mode? I always make sure I use strict mode (full standard mode) and that mode renders best across different browsers and is the way forward. Everything else, quicks mode, is just legacy war damage from the ancient browser battles .
    • M

      Minimize WebDialog from code?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      5
      0 Votes
      5 Posts
      292 Views
      D
      maybe I'm missing the point... @dlg.set_size(100,100) @dlg.set_position(100,100) @dlg.set_size(1000,1000) @dlg.set_position(100,100) can switch between 2 sizes at the same position... john
    • M

      Change plugin variables within Undo

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      320 Views
      danielbowringD
      you could store the value/flag on the model instead, then it would also change with the undo steps model = Sketchup.active_model model.set_attribute('maricanis', 'dl_materials_changed', true) #... model.get_attribute('maricanis', 'dl_materials_changed', false)
    • M

      Detect changes in geometry?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      7
      0 Votes
      7 Posts
      258 Views
      thomthomT
      @maricanis said: However, I've never used start_operation and Undo related features, so this is good opportunity to look them too. Indeed - they are essential for a good UX so the user an go back and forth. Another note on the ToolsObserver - the tool state of the tools vary and are not consistent so you need to dig a little to figure out their behaviour. I described some of the behaviour of Move, Rotate and Scale in the comments of AutoSmooth. You can view the source at GitHub: https://github.com/thomthom/AutoSmooth
    • M

      Number of processors

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      262 Views
      TIGT
      num = ENV['NUMBER_OF_PROCESSORS'].to_i is much easier than the other way and should be fine unless you want to have a cross-platform solution... We don't know if MAC has the same ENV variable 0 - some references are similar to PC, while others can be the same ??
    • M

      Kill external process

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      7
      0 Votes
      7 Posts
      263 Views
      M
      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
    • M

      Position_material problem

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      7
      0 Votes
      7 Posts
      238 Views
      M
      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
    • M

      Extend view.write_image?

      Watching Ignoring Scheduled Pinned Locked Moved Developers' Forum
      4
      0 Votes
      4 Posts
      143 Views
      Dan RathbunD
      @unknownuser said: (referring to Windows ALT+PrintScreen manual workaround.) ..., but I needed some to write a code to save and image from my plugin. You may on Windows only, use Win32OLE.so and the SendKeys() function.
    • 1 / 1