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

    rvs1977

    @rvs1977

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

    rvs1977 Unfollow Follow
    registered-users

    Latest posts made by rvs1977

    • RE: How to use special characters in filenames like æøå

      Hej Thom,

      Then it sounds like I have to switch to Sketchup 2014 😄

      posted in Developers' Forum
      R
      rvs1977
    • How to use special characters in filenames like æøå

      Hi!

      This one might be though, since most of you are US-Guys. But if you come from an ancient country like mine you have special characters like æøå.

      And that appears to be a problem if you want to save a file with a name containing letters like æ, ø or å.

      Do you have any ideas how to fix that?

      -Rasmus

      posted in Developers' Forum
      R
      rvs1977
    • RE: How to save the model to a file?

      @sdmitch said:

      Interesting! In the Ruby Console, type ENV and press Enter. Does that show anything? How about ENV['HOME'].

      When I type ENV in Ruby Console:

      "PUBLIC"=>"C:\\Users\\Public", "SESSIONNAME"=>"Console", "SystemDrive"=>"C:", "SystemRoot"=>"C:\\windows", "TEMP"=>"C:\\Users\\RASMUS~1\\AppData\\Local\\Temp", "TMP"=>"C:\\Users\\RASMUS~1\\AppData\\Local\\Temp", "USERDOMAIN"=>"RasmusVS-pc-Pc", "USERNAME"=>"RasmusVS-pc", "USERPROFILE"=>"C:\\Users\\RasmusVS-pc", "windir"=>"C:\\windows", "windows_tracing_flags"=>"3", "windows_tracing_logfile"=>"C:\\BVTBin\\Tests\\installpackage\\csilogfile.log"}

      As you can see there is no ENV['Home'] variable.

      I would use ENV['USERPROFILE'] instead.

      I use Sketchup 8.0.15158 - Maybe thats why...?

      posted in Developers' Forum
      R
      rvs1977
    • RE: How to save the model to a file?

      @sdmitch said:

      ENV['Home'] is your user account, ie C:/Users/Rasmus. In this case filename would equal 'C:/Users/Rasmus/Desktop/mysketchup.skp'

      Great, thanks! I figured it out with your help 😄

      model = Sketchup.active_model status = model.save('d:/rs_model.skp')

      But ENV['Home'] dont seems to work.
      I have tried:
      test = ENV['Home'] puts(test.to_s)

      and nothing shows...

      posted in Developers' Forum
      R
      rvs1977
    • How to save the model to a file?

      Hi!

      How do I save the model to a file?

      I have tried the following but it don't seems to work.

      ` model = Sketchup.active_model

      Save the model using the current SketchUp format

      filename = File.join(ENV['Home'], 'Desktop', 'mysketchup.skp')
      status = model.save(filename)`

      And can anyone tell me what ENV['Home'] is?
      And if I want to save to a diffenrent location than desktop will it then be, eg:
      'c:\my\project\folder'?

      Thanks in advance

      -Rasmus

      posted in Developers' Forum
      R
      rvs1977
    • RE: EntitiesObserver and attributes

      Great, this solved my problem! Thank you very much Dan! 😄

      posted in Developers' Forum
      R
      rvs1977
    • RE: EntitiesObserver and attributes

      @dan rathbun said:

      Problem is you are already within the EntitiesObserver instance attached to the Group's Entities collection !
      You must be careful not to set up an infinite loop !

      Changing the model from within observer callbacks can crash SketchUp !

      Ok, for now I will abandon this approach.

      Please consider this example:

      
      mod = Sketchup.active_model
      ent = mod.entities 
            i = 0		
      		h= {}
      		ent.each do |o|
      		attr = o.get_attribute "rsdict","area"		
          
      			if attr 					
      			   h[i] = {'structid' => 201, 'area' => attr}		
      			   i += 1;			
      			end
      		end
      

      Here it scans the entire model for groups with the attribute_dictionary "rsdict", "area".

      Lets say it finds a group with the "rsdict" attribute. Inside the group there are a face
      with an attribute attached to it.

      Is it possible to scan that group for all its entities? Something like this:

      
      mod = Sketchup.active_model 
      ent = mod.entities 
            i = 0		
      		h= {}
      		ent.each do |o|
      		attr = o.get_attribute "rsdict","area"		
          
      			if attr
                                 o.entites.each do |u|
                                 yv_face_area = u.get_attribute "rsdict", "yv_face_area"
      
                                 if yv_face_area
                                     h[i] = {'structid' => 201, 'area' => yv_face_area}			                       i += 1;
                                 end		  			
      			end
      		end
      
      posted in Developers' Forum
      R
      rvs1977
    • RE: EntitiesObserver and attributes

      Thank you Dan, but I try to explain it again:

      My goal is to set an attribute to the group when a face has been modified. As you can see in the code below Im able to set an attribute to the face inside the group, but not the group containing the face. Do you have any ideas how to work around this problem?

      If the group is called rsgroup:

      yv_face_height = rsgroup.entities.add_face pts[0..3]
      rsgroup.set_attribute "rsdict","area", yv_area
      yv_face_height.set_attribute "rsdict", "yv_face_area", yv_area

      class MyEntitiesObserver < Sketchup;;EntitiesObserver        
          def onElementModified(entities, entity)    
              
              attr_area = entity.get_attribute "rsdict", "yv_face_area"       
      				
                      if attr_area
                          yv_area_new = i.area.to_m.to_m                          
                          entity.set_attribute "rsdict", "yv_face_area", yv_area_new
      
                          #(HERE I WOULD LIKE TO SET THE ATTRIBUTE OF THE GROUP-something like;)
                          entity.parent.set_attribute "rsdict","area", yv_area_new
      			
                      end #attr_area       
              
          end #onElementModified_end   
      end #class
      
      posted in Developers' Forum
      R
      rvs1977
    • EntitiesObserver and attributes

      Hi,

      Im working with EntitiesObserver, and having trouble understanding the method
      def onElementModified(entities, entity).

      For instance, if you add an EntitiesObserver to a group consisting of a face, the EntitiesObserver will fire when you doubleclick the group and alter the face.

      (Eg. moving one of the edges so that the area of the face will increase.) In that case it will fire 3 times because 2 edges will get longer, and the face itself will increase in size.

      If you have set an attribute to the face it is then possible to retrieve the value by saying
      myFaceAttr = entity.get_attribute "rsdict", "face_attr", and you can set a new value with set_attribute "rsdict", "face_attr", "new value".

      But now my question is: what if I have an attribute set to the group, and I want to alter that when the EntitiesObserver fires. Is it possible to see name of the parent of the entity? (The face is a child of the group)

      Hope the question is understandable... 😒

      -Rasmus

      posted in Developers' Forum
      R
      rvs1977
    • RE: EntitiesObserver and Attributes - work around

      Ok. hopefully there is a solution. If I find one I will return...

      posted in Developers' Forum
      R
      rvs1977