sketchucation logo sketchucation
    • Login
    1. Home
    2. Pout
    3. Posts
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    P
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 57
    • Posts 259
    • Groups 1

    Posts

    Recent Best Controversial
    • 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
    • RE: Looping all entities

      ThomThom

      Thanks for the fast reply!
      I did the test on a single box (not a group nor instance) and even then it went wrong
      So I can assume that Sketchup.active_model.entities.each{|e|
      ...
      }
      can always be incorrect even when just checking for something (eg. check if the current entity has a certain value in it's attribute dictionary)?

      On point 1, what would be faster

      Sketchup.active_model.entities.to_a.each{|e|
      check=e.get_attribute'x','y'
      if check==1
      e.erase!
      end
      }
      

      or

      test=[]
      Sketchup.active_model.entities.to_a.each{|e|
      check=e.get_attribute'x','y'
      if check==1
      test<<e
      end
      }
      model.entities.erase_entities(test)
      
      posted in Developers' Forum
      P
      Pout
    • Looping all entities

      I'm a bit puzzled.

      Sketchup.active_model.entities.each{|e|e.erase! if e.valid?}
      works but doesn't delete all entities

      Sketchup.active_model.entities.to_a.each{|e|e.erase! if e.valid?}
      works and deletes all entities

      Now, does this mean that to loop all entities in a model i always have to put them in an array first?
      I never have run into any problems before using the first method.

      Additionaly

      f=0
      Sketchup.active_model.entities.each{|ent|
      	f+=1
      	Sketchup.active_model.selection.clear
      	Sketchup.active_model.selection.add ent
      	ent.erase!
      }
      puts f
      

      returns 4095 (on a 11200 entities model)
      while

      f=0
      Sketchup.active_model.entities.each{|ent|
      	f+=1
      	Sketchup.active_model.selection.clear
      	Sketchup.active_model.selection.add ent
      	#ent.erase!
      }
      puts f
      

      returns 11200 (on a 11200 entities model)

      I must be missing something essential here... 😲 ❓ ❓

      posted in Developers' Forum
      P
      Pout
    • RE: Update entity by webdialog/excel

      a little bit more information:

      Standard DC definition attributes (dynamic_attributes):
      Retrieve with (for the selected instance):

      xx=Sketchup.active_model.selection[0].definition.attribute_dictionaries['dynamic_attributes']
      xx.each{|key,value| puts key.to_s+'-'+value.to_s}
      

      Returns (app. depending on user set attributes of the selected instance-in this case LenX and LenY are 'user cannot see' and material is 'user can see'):
      _formatversion-1.0
      _has_movetool_behaviors-0.0
      _hasbehaviors-1.0
      _lastmodified-2012-02-21 10:13
      _lengthunits-CENTIMETERS
      _lenx_access-NONE
      _lenx_formlabel-LenX
      _lenx_label-LenX
      _lenx_units-DEFAULT
      _leny_access-NONE
      _leny_formlabel-LenY
      _leny_label-LenY
      _leny_units-DEFAULT
      _material_access-VIEW
      _material_formlabel-Material
      _material_label-Material
      _material_units-STRING
      _name-Huis1
      lenx-393.700787401575
      leny-393.700787401575
      material-

      When changing LenX and LenY to 'user can see':
      _formatversion-1.0
      _has_movetool_behaviors-0.0
      _hasbehaviors-1.0
      _lastmodified-2012-02-21 10:15
      _lengthunits-CENTIMETERS
      _lenx_access-VIEW
      _lenx_formlabel-LenX
      _lenx_label-LenX
      _lenx_units-DEFAULT
      _leny_access-VIEW
      _leny_formlabel-LenY
      _leny_label-LenY
      _leny_units-DEFAULT
      _material_access-VIEW
      _material_formlabel-Material
      _material_label-Material
      _material_units-STRING
      _name-Huis1
      lenx-393.700787401575
      leny-393.700787401575
      material-

      Standard instance attributes (dynamic_attributes):

      xx=Sketchup.active_model.selection[0].attribute_dictionaries['dynamic_attributes']
      xx.each{|key,value| puts key.to_s+'-'+value.to_s}
      

      _has_movetool_behaviors-0.0
      _hasbehaviors-1.0
      lenx-393.700787401575
      leny-393.700787401575

      Now if you add an attribute on definition level eg. LenX this is accessible as lenx for both the comp. definition as the instance.
      Important: to be able to access that value on instance level with _lenx_formula (eg. to change the value) the attribute must be set to at least 'users can see this attribute' . Otherwise it cannot be changed through ruby.

      If I get out more information, I'll post it here.

      posted in Developers' Forum
      P
      Pout
    • RE: Update entity by webdialog/excel

      Indeed.
      I'm looking into DC but there's not a lot of info.
      So maybe someone already developed something like this, so I can learn from it.

      On the other hand, when I have a model in which 1 DC definition has two instances and I update on of those instances:
      framing_wall_instance = Sketchup.active_model.entities[0]
      framing_wall_definition = framing_wall_instance.definition
      ad = framing_wall_definition.attribute_dictionary "dynamic_attributes"
      ad["_lenx_formula"] = '275.447'
      $dc_observers.get_latest_class.redraw_with_undo(framing_wall_instance)

      The other one does not seem to change.
      Even more when I place an new instance in the model, it shows the 'original' component, but when placing it (click) it updates and is then equal to the edited instance.
      Probably logical but I don't see why

      posted in Developers' Forum
      P
      Pout
    • Update entity by webdialog/excel

      Just a question (before creating it myself):
      Is there any plugin/script/... which updates an Entity/Component/Group when it's parameters are changed in an external 'interface' (can be a webdialog or an excell sheet)

      Basically, when you update the parameters of the object by hand (type new values in a cell or input textfield) and hit a button in Sketchup the object is adapted.

      Thx in advance!

      posted in Developers' Forum
      P
      Pout
    • RE: BIM for SketchUp - again?

      brewsky and others

      Based on your comments, there are two possible pathways:
      BIM as in: be able to attach BIM properties and parameters to an entity. That's it, these parameters do not influence the entity when changed.
      BIM as in: when changing IFC parameters/properties teh entity is changed accordingly, even more, when adjectent entities are influenced they also change if needed (bit like Revit)

      As you can see, the first option is easy, but what is the added value?

      brewsky, can you pm me your contact info, I'm located in Belgium, maybe we can have a chat.

      posted in Plugins
      P
      Pout
    • RE: BIM for SketchUp - again?

      It's a lot on how far do you want to go? And how many Sketchup users have the need for BIM?

      Get/Send data from and to a database from Sketchup is not that hard, we already do it in our software.
      Link images, costs, planning, resources can be done already. Show it in charts, automated powerpoints, movies, automatically created BOQ or BOM. We have prototypes developed for this.

      I'm not trying to sell anything here, I'm just saying that the technical part is not the issue.
      The main issue is the communication between all CAD/BIM software and Sketchup in both ways. And if IFC is the 'magic' format.

      I'm very fond of the idea of trying to create a certain level of BIM into Sketchup, to have the opportunity to get the information you want into the model and get added value out of it. But the interchangeability is an important factor.

      posted in Plugins
      P
      Pout
    • RE: Moving object in steps

      i got it, will post solution later

      posted in Developers' Forum
      P
      Pout
    • RE: Moving object in steps

      Thomthom, different operations
      So there can be other commands in between.
      With the object I mean a section plane
      So I'll need to use transform_entities or transform_by_vector

      posted in Developers' Forum
      P
      Pout
    • RE: Moving object in steps

      some extra info:
      it's a section plane i try to move

      posted in Developers' Forum
      P
      Pout
    • 1 / 1