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

    Posts

    Recent Best Controversial
    • RE: Plane from current view

      OK, that got me close. Does anyone know how to convert the viewport coordinates from pixels to actual coordinates? Ideally I would be able to create a rectangle the same size as the viewport corners, write the current view image, manipulate the image (outside of SU), apply back to this rectangle and project to the model. I can generate a correctly oriented rectangle using the eye, target, and up camera methods, but now I am struggling with sizing it correctly.

      I do not believe the model bounds will not work because I need to be able to work in any orientation and any zoom level to affect specific locations of the model.

      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: Plane from current view

      Thanks TIG

      posted in Developers' Forum
      J
      JonD
    • Plane from current view

      I am trying to figure out where to start on this:

      I would like to create a rectangular plane from the current camera position to essentially create a work plane from the current view. The end-game will allow me to place an image on this plane for projection onto a terrain model. My thought is that I could export a 2D image of the current view of a terrain model (imported through the geolocation in Earth), edit it in an image editor to 'dress it up', then place the edited image on the work plane and project the edited image as a texture on the model...maybe someone has tackled this already...

      My guess is that I can get a 3D vector of the camera point to target and the 'up' vector. I would need the normal vector to both of these to create the plane's vectors. I am not sure how to make the corner points (projected from the model bounds) to make the rectangle on this plane.

      Thanks in advance,
      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: SKM files

      Thanks for the good information. Has anyone submitted an enhancement request to Google for some SKM read/write api?

      Jon

      posted in Developers' Forum
      J
      JonD
    • SKM files

      OK, I know there are some older posts out there, so this is a long shot...Is there a way to load SKM files and add them to the Sketchup.active_model.materials collection? I have tried some of the obvious methods, but have not had luck. I am trying to save some attributes in an attribute library attached to the material. I can see that the attribute library is saved in the skm file (changed it to zip and looked at the xml). It also reloads the attributes correctly when I use it from the material window - so it basically works. I would like to apply the materials to some of the object using ruby...

      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: 'Check for Updates' Script

      @unknownuser said:

      Jon,

      It is relatively easy to perform the check of whether the version on the web (and then comare with the one currently installed locally).

      The real difficulty is to download the file and install it when it is in binary format (for instance a Zip file). It is possible for a .rb file which is plain text however.

      Fredo

      PS: I would use Whaat's method, which is to check periodically, even letting the user set the next date. If all scripts do their check at each SU statup, then it would take too long.

      You are right on with the downloading difficulty. I originally wanted to have each 'dependent' represented in the version string so I could only download the file that needed updating. Unfortunately, I could not find a clean way to initiate a download of a .rb or .rbs file into the plugins directory. I have resorted to having the link point directly to a download of an installer (.exe) and the installer is handling the file moves to the plugins folder. It is an acceptable solution for me.

      I have changed my script so that the update is user initiated through the plugin commands. Again, thanks to all for the help.

      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: 'Check for Updates' Script

      Thanks for the direction. Here is how I ended up doing it - very close to Whaat's method. The main difference is I am loading a very small page in the web dialog, not getting the contents of the text file. I had trouble getting the $.get method to work...javascript newbie, I am...

      This is the code in the ruby script. I basically open the webdialog during the startup of Sketchup. The web page loaded in the dialog (from my server) just returns the current build code. I had to add the UI.start_timer to pause a second to let the javascript happen, then close the web dialog

      
      	current = $current.to_s
      	if Sketchup.is_online
      		ssupdate = UI;;WebDialog.new("Check for Updates", false, "Check for Updates", 200, 200, 200, 200, true)
      		ssupdate.add_action_callback("check_current_version") {|d,p|
      			version=p.to_s
      			
      			if version>current
      				text="A newer version of Lakefront Layout is available. Would you like to update?"
      				result=UI.messagebox(text,MB_YESNO)
      				if result==6 #yes
      					UI.openURL("http://www.shorestation.com/")
      				end
      			end
      		}
      		ssupdate.set_url("http://www.shorestation.com/IPADock/Sketchup/checkupdate.html")
      		ssupdate.show
      		
      		id = UI.start_timer(1, false){ssupdate.close}
      	end#if
      
      
      

      Here is the html file I have on y website:

      the 20111112 is the date code of the latest build. This is what I edit when I want to push a new update.

      
      <html>
      <script>
      function check_current_version() {
      	
      	window.location='skp;check_current_version@'+20101112;
         
      }
      window.onload = check_current_version()
      </script>
      <body>
      </body>
      </html>
      
      
      

      I am sure this is not the greatest approach, but it is working. Again, thanks for the help -great forum!

      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: 'Check for Updates' Script

      That is perfect! Thanks for the post.

      posted in Developers' Forum
      J
      JonD
    • RE: 'Check for Updates' Script

      Thanks all, I have check these out and post what I come up with.

      Jon

      posted in Developers' Forum
      J
      JonD
    • 'Check for Updates' Script

      Has anyone had any luck making a script that automatically updates. I would like to somehow check the script version against my website and offer to download an update if one exists. My initial thought was to have a text file on the website that contains a version number. The script would check the version number in the text file when it loads (if online) and then prompt the user to download the updated files directly into the plugins folder. I am sure it is not as easy I am making it sound...

      Has anyone tried this? If so, please share!

      Thanks,
      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: Snap Alignment

      I had to make a 'predefined' snap location for accessories for our dock builder plugin for Sketchup. I basically created 'balloon' components that were layered on the model. When the user activates the tool it shows the layer containing the balloons. If the user clicks on the balloon, I replace the component definition with the accessory they chose. You can check it out in action in this video: http://www.youtube.com/watch?v=SMZfBORI9wI

      I am using a combination of dynamic component attributes and component definitions to make it work. It may not be the most elegant solution, but it seems to work.

      Jon

      posted in Developers' Forum
      J
      JonD
    • Dynamic Components Window

      Is it possible to open the "Component Options" window via ruby? It is not part of the 'inspectors' and I cannot find a send_action method. This would be the window that opens through the Window/Component Options menu.

      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: Dynamic Component Redraw

      Many thanks Scott, Thom and Chris. I will give this a try when I get back to the workstation.

      posted in Developers' Forum
      J
      JonD
    • RE: [Plugin] Dynamic Component BOM

      Thanks...I am not familiar with the script submission process on Sketchucation. Is there information on the website on how to submit?

      Jon

      posted in Plugins
      J
      JonD
    • [Plugin] Dynamic Component BOM

      Ok...this is my first script that I thought I would share. The attached script will generate a summarized list (Summary BOM) of dynamic components that have a value in the ItemCode attribute. It will also record the Description DC attribute. By default the script will create an HTML report, but it will create a csv by just changing the extension to '.csv'.

      Scott Lininger provided most of the base code, I just tweaked it around a bit. Thanks for the help Scott! This was my first attempt at a ruby script, so let me know if I have any completely wrong approaches here...

      Jon
      Dynamic Component Summary BOM

      posted in Plugins
      J
      JonD
    • RE: Dynamic Component Redraw

      Nothing yet...

      posted in Developers' Forum
      J
      JonD
    • Dynamic Component Redraw

      Is there an observer to catch the 'event' when a user applies a change to a dynamic component that causes it to redraw? I need to beable to force a redraw of another dynamic component if a change happens to another. I thought I saw something on a dynamic component observer, but I cannot find any documentation on it...

      Thanks,
      Jon

      posted in Developers' Forum
      J
      JonD
    • RE: Dynamic Component Copies and Transformation

      Ok, maybe this is totally unclear, so here is part of the code. I am using the method that Jim posted for 'cruising' throught the multiple levels (components, groups, and subcomponents) of the model:

      
      list = Array.new
      Sketchup.active_model.entities.each do |i|
      	list << {;item => i, ;trans => nil }
      end
      while list != []
      	list.each do |i|
      		item = i[;item]
      		type = item.typename
      		parenttrans = i[;trans]
      		case type
      			when "Group"
      				trans = item.transformation
      				trans = item.transformation*parenttrans if parenttrans
      				item.entities.each do |entity|
      					group_list << {;item => entity, ;trans => trans }
      				end
      				#get the attributes and put them in the report string
      				group_list.delete(item)
      			when "ComponentInstance"
      				name = get_attribute_value(item, 'name')
      				trans = item.transformation
      				trans = item.transformation*parenttrans if parenttrans
      				bbox = item.bounds
      				point = bbox.max.transform(parenttrans)
      				x = point.x
      				puts("x maximim; " + x.to_s)
      
      				item.definition.entities.each do |entity|
      					component_list << {;item => entity, ;trans => trans}
      				end			
      				#get rid of the item we have already examined in the list
      				component_list.delete(item)
      			end
      		end
      	list = group_list + component_list
      	group_list.clear
      	component_list.clear
      	end
      end
      

      I changed the method a bit to accumulate the transformation of the parents. It seems to work OK except for components in the model that are duplicated using the 'copies' dynamic component attribute...if anyone can shed light on this or has another method of getting the absolute location of a component, no matter how deeply nested, please post.

      Thanks,
      Jon

      posted in Developers' Forum
      J
      JonD
    • Dynamic Component Copies and Transformation

      I have a script I am writing that I need the maximimum X distance from the model origin. The model contains dynamic components that are 'patterned' using the DC attribute 'Copies' to pattern along the x axis. There are multiple sub components in the model that each contain multiple copies using the DC Copies attribute. I am finding the max X by using the max point of the bounding box for the component and grabbing its X value. I am applying the tranformation of the parent (group or component instance) to the point to the max point. It seems that the transformation is not being applied correctly to the dc copies. The original DC of the copy is reporting correctly. Is the transformation of the copies (i.e. COPY >=1) based on the origin of the original DC? If so, any suggestions for managing the transformations correctly?

      Thanks,
      Jon

      posted in Developers' Forum
      J
      JonD
    • Apply transformations to nested DC components

      I have a model of a dock system. The system contains 4'x8' Dynamic components that are 'patterned' using DC functions based on the 'copies'. The model contains nested components that make the dock system into an L or T shape. I am trying to write a script to find the X axis location of each section with respect to the model origin and modify a DC value 'waterdepth' based on the x axis location.

      My initial approach is to get the x axis value of a vertice of the bounding box, but I do not know how to apply the parent transformations of the nested components. Is there a better way of find the bounding box location with respect to the top level model origin? The bounding box method is working for first level components, but the lower level components return untransformed values.

      Hopefully this is clearer than mud...

      posted in Developers' Forum
      J
      JonD
    • 1 / 1