sketchucation logo sketchucation
    • Login
    1. Home
    2. Pout
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here
    P
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 57
    • Posts 259
    • Groups 1

    Pout

    @Pout

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

    Pout Unfollow Follow
    registered-users

    Latest posts made by Pout

    • RE: Observers work differently depending on how Sketchup starts?

      @dan rathbun said:

      The API docs say this won't work... because the file is already open (on PC,) by the time the AppObserver gets loaded.

      Dan,
      In my script:
      When double-click on SU file

      1. opening the model in SU
      2. execute PRODUCE.sceneobserver (automatically)
      3. A Appobserver is also created (which fires PRODUCE.sceneobserver again, but since there already is an observer there is no new one created)
      4. When a model is then opened from the file menu the Appobserver is called

      Logically and after testing this seems to work ok.

      My code here is not complete though, since in my code there is another check to see if the framobserver must be created or not (depending if the opened model has some specific settings)

      posted in Developers' Forum
      P
      Pout
    • RE: Observers work differently depending on how Sketchup starts?

      Dan,

      I have done some testing with this and it seems to work yes.

      Thx for cleaning up the script!

      posted in Developers' Forum
      P
      Pout
    • RE: New URL for SketchUp's API documentation

      For me it's simple:

      For registered users give the opportunity to comment on incorrect information/give more explanation and give possibility to add code examples. I always like the way PHP does it: http://php.net/manual/en/function.include.php

      If you give us the tools, we help you with the content...

      posted in Developers' Forum
      P
      Pout
    • RE: Observers work differently depending on how Sketchup starts?

      We needed a Sceneobserver being attached whenever a model is openend (through the menu item or when double clicking a skp file in Windows Explorer.
      And did it like this:

      Ath the end of the ruby file:

      PRODUCE.sceneobserver
      # Observer that watches the application for opening of models from the file menu and creates scenes observer automatically.
           class MyAppObserver < Sketchup;;AppObserver
             def onOpenModel(model)
      			PRODUCE.sceneobserver
         end
      end
      

      This handles both possibilities.
      Now to avoid creating 2 observers just check if there is already an observer present

      
      def PRODUCE.sceneobserver #add the scene observer after PRODUCE.scenes or when scenes need to be reloaded
      	#
      	if ($xDframesobserverid==nil or $xDframesobserverid=='') #no frame observer existing or it has been removed
      	#UI.messagebox ('make observer')
      		$xDframesobserverid=Sketchup;;Pages.add_frame_change_observer(XdFrameObserver.new) 
      	end
      end
      

      Hope this helps

      posted in Developers' Forum
      P
      Pout
    • RE: Rubber Duck Debugging

      'explains code to an inanimate object'
      I'd prefer this:

      http://1.bp.blogspot.com/_24OPxC7O5lk/TA0hjoPflOI/AAAAAAAAAQk/rbM_CLSynSk/s1600/beer.jpg

      Downside is that after a while you'll need to debug what you are saying πŸ˜„

      posted in Developers' Forum
      P
      Pout
    • RE: Component definition list from Ruby vs SU window

      great, thank you both for the information!

      posted in Developers' Forum
      P
      Pout
    • RE: Component definition list from Ruby vs SU window

      ok, hitting 'Expand' would be a good idea 😳 😳 😳 😳

      posted in Developers' Forum
      P
      Pout
    • Component definition list from Ruby vs SU window

      I use this code to list all used component definition names:

      def TESTXD.listcompnames1
      		$componentnames=[]
      		Sketchup.active_model.entities.each{|e|
      			TESTXD.listcompnames2(e)
      		}
      		$componentnames.uniq!
      		$componentnames.sort!
      		puts ($componentnames)
      	end
      	def TESTXD.listcompnames2(e)
      		theclass=e.class
      		if theclass==Sketchup;;Group 
      			gen=e.entities
      			gen.each{|gent|
      				TESTXD.listcompnames2(gent)
      			}
      		elsif theclass==Sketchup;;ComponentInstance
      			$componentnames<<e.definition.name
      			e.definition.entities.each{|ent|
      				TESTXD.listcompnames2(ent)
      			}
      		end
      	end
      

      This gives me a list in the ruby console.
      Now if I compare this list with the list shown in the components windows I see that certain definitions are available in ruby but not in the components window.

      Is this due to the fact that those component definitions are only used in nested component definitions? That makes no sense.
      Or maybe I'm missing something.

      posted in Developers' Forum
      P
      Pout
    • RE: Looping all entities

      Excellent information.
      Thank you ThomThom, much appreciated!

      posted in Developers' Forum
      P
      Pout
    • RE: Looping all entities

      @thomthom said:

      What went wrong? Examples?

      It goes wrong caused by the fact that the entities object is edited while executing the loop. So as you stated.

      http://www.dstudiofs.eu/webimages_temp/deletall1.jpg

      http://www.dstudiofs.eu/webimages_temp/deletall2.jpg

      @thomthom said:

      No, just when you modify it. If you just read states and properties there should be no problems.

      Modify (like in push pull) or only when the entity is deleted?

      @thomthom said:

      The second - using .erase_entities.

      In the second case I could use Sketchup.active_model.entities.each (without the to_a) Correct? And if so would that be faster then with to_a?

      Thx again!

      posted in Developers' Forum
      P
      Pout