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

    Posts

    Recent Best Controversial
    • RE: Quick theoretical question

      Wow that sounds really cool, and totally outside my skill level 😛 I just said MySQL/PHP since i did GeoWeb stuff before, its probably not too practical in this situation.

      I hope you don't mind if summarize what you said into a few sentences and slide it right into my thesis 😄

      I'll be sure to give you (and everyone else from this site who without my thesis work would of failed) a shout out in my acknowledgments.

      Out of curiosity, is the work your doing (mtalbott) going to be released publicly one day? or is it personal use? I'm always looking at new ways get citizens designing collaboratively with different visualization methods, and what you described has sooooo much potential.

      Cheers,
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      very cool!, you said each cube is an instance, could you swap out the definition to make an object composed to a bunch of tiny anythings? could auto scale the component to fit in your cube, then make all sorts of crazy things.

      also, not that it matters, but it seems like the red face matches the red axis, but the blue face follows the green axis and the green face follows the blue axis. Intentional?

      posted in Plugins
      K
      kdasilva
    • Quick theoretical question

      Hi again,

      I am just writing up the conclusion for my thesis and was asked by my prof to speculate about better integration with web 2.0 services. Without really needing any detail per say could anyone speculate into the possibilities of sharing sketchup information between computers live through web-dialogs or something. I was thinking maybe something with PHP/MYSQL could share variables information....but it would probably be pretty limited..every entity would have to be broken down to coordinates or something? Any way, wild speculation is welcome, like i said its just for a consideration in my conclusion.

      Cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: Have moved to Linux Mint 10. Sketchup in Linux?

      As for Sketchup going to Linux,

      Aidan Chopra (the Sketchup product evangelist) spoke at my uni about a month back and someone asked about plans of Sketchup going to Linux. He was pretty clear that it wasn't on Google's list of things do.

      posted in Developers' Forum
      K
      kdasilva
    • RE: Attribute dictionary in callback

      I appreciate all your help, but I am still unsure on why my get get_attribute method would return nil in a different call back? is there a scope issue I am not accounting for? the get_attribute works within the same callback so I am lead to believe that the instance name is working as a key...

      posted in Developers' Forum
      K
      kdasilva
    • RE: Attribute dictionary in callback

      @tig said:

      You CAN set/get attributes for the model, a definition, an instance or any other 'entity' for that matter...

      So you need to decide the best way to do what you want...

      If the user is selecting an instance and giving it a 'description' you can set that as an attribute for the instance itself. To get the values later set up something that does this type of thing model.definitions.each{|defs|d.instances.each{|i|###code to check the type and attributes etc###}}
      IF certain things are true you can then add those as variables /a to an array etc...
      OR if you know the few components that you want to check then just limit your check to those... by name compo1="myCompoA" etc... and the collection is insts=[] [compo1,copmo2,compo3,compo4].each{|cname| arr=[]; model.definitions[cname].instances.each{|i| arr << i if i.get_attribute==???}; insts << arr}
      Now 'insts' contains all of the matching instances...

      I dont understand why I need all of these arrays etc...I was thinking I just needed a dictionary I can save to the model, or that particular layer...which inside simply has a key (the instance unique identifier, ie name) and an associated attribute (the description), from this if I wanted all of the descriptions I can just grab the whole dictionary and iterate through it....

      posted in Developers' Forum
      K
      kdasilva
    • RE: Attribute dictionary in callback

      @tig said:

      Perhaps to need to explain it better is 'words' rather than code snippets that don't tell the whole story.

      sure~

      Basically the user starts by using a icon to place and size instances around the map, [this part works good]

      then they are supposed to be able to select an instance write a description of (ie why it was placed their etc) and then push a button in the webdialog that takes the selection, and the text in the (the description variable you asked about) and should then store the description as an attribute, so later you can select a instance, push "view" and the description can be read in the webdialog GUI. There are four different component definitions, so the code takes the selection, checks which definition it has, and then should add or replace the attribute assigned to the the key (the particular instance)

      should I perhaps be making the dictionary for the definitions themselves?? But how do I create a dictionary without first having a key->attribute to initialize it with.....hmm I think I just confused myself more...so I dont know if that description helped

      thanks!
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • Attribute dictionary in callback

      Hello I had hopefully a quick question that I cant seem to find the answer,

      I am having trouble getting information from an attribute dictionary i created in a different callback, for example:

      
      elsif diagnosis_selection.definition == comp_def_R
      	new_R_dictionary = model.set_attribute "repairdictionary", diagnosis_selection.to_s, description
      	print_R_dictionary = model.get_attribute "repairdictionary", diagnosis_selection.to_s
      	js_update_command = "UpDateDiagnosis(\""+ print_R_dictionary +"\")"
      	web_dialog.execute_script(js_update_command)
      
      

      (description is text passed through the webdialog, assigned as an attribute to a instance where its name being the key)

      However when trying to access the same attribute dictionary in a separate callback:

      
      print_R_dictionary = model.get_attribute "repairdictionary", diagnosis_selection.to_s
      puts print_R_dictionary
      
      

      I keep getting nil, when having the same instance selected. how I can I make two seperate callback read the same attributes. I have done it in other parts of my app, however there the attributes is initialized outside of the callbacks...but here I cant create them until I have the keys and this happens in the first callback....

      any help appreciated...I I'm presenting at a conference across the country on the project and urban design visualization so i'm hopping to have as much working as I can.

      Cheers~
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: .execute_script interesting quirk

      @tig said:

      I have several custom tools using href button with rounded ends etc instead of standard buttons - this way [you define the button class in your css style code] - the call_backs work fine - here's a snippet...

      <span class="syntaxdefault"><br /></span><span class="syntaxkeyword"><</span><span class="syntaxdefault">td align</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">center style</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"width;84px; padding;3px;"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">a id</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"cancel_dropdown"</span><span class="syntaxdefault"> <br />         class</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"button"</span><span class="syntaxdefault"> href</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"#"</span><span class="syntaxdefault"> <br />         onclick</span><span class="syntaxkeyword">=</span><span class="syntaxstring">"this.blur(); window.location='skp;cancel_dropdown@';"</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword"><</span><span class="syntaxdefault">span</span><span class="syntaxkeyword">></span><span class="syntaxdefault">Cancel</span><span class="syntaxkeyword"></</span><span class="syntaxdefault">span</span><span class="syntaxkeyword">><br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword"></</span><span class="syntaxdefault">a</span><span class="syntaxkeyword">><br /></</span><span class="syntaxdefault">td</span><span class="syntaxkeyword">></span><span class="syntaxdefault"> </span>
      

      even the .execute_script command? everything else works for me too except for that....although looking at your code it may be because i used:

      <a href="javascript:AddChangeDiagnosis()" ><b>[Add/Change]</b></a>

      to call the function, whereas both my buttons and the image i click use the "onclick" attribute

      ** confirmed....that was the problem, sooo take home lesson...always use "onclick" !

      posted in Developers' Forum
      K
      kdasilva
    • .execute_script interesting quirk

      I thought this experience would be worth sharing in case anyone else gets stuck like i did~

      So i don't know if this qualifies as a "bug" per say...but it definitely made my morning long and frustrating.

      Has any one else noticed that if you create an action_callback through clicking on a <a href...> tag instead of a button, the .execute script command no longer works on the web_dialog parameter. Correct me if Im wrong but I spent all morning testing this problem with two cal_backs that were essentially identical. It took me several hours to realize that the only difference was one got created through a button, and the other through a hyperlink

      everything else I worked in the callback except for .execute_script for the record

      (I was just using hyper-links because the buttons were so ugly)

      It would be interesting to see if other methods of creating a call_back in a webdialog have this bug.

      cheers
      Korbin

      *Update I did a quick test on a callback created through clicking on an image I have in my app, and it worked fine...verrrrry interesting

      posted in Developers' Forum
      K
      kdasilva
    • RE: Transformation Troubles

      @tig said:

      Transformations need to be done in a logical sequence if you use * they read right to left in sequence of application.
      If you manually locate, then rotate about a point and then scale an object you WILL get a different end result than if you locate, scale and then rotate it... It's the same with a coded transformation. Keep track of the points etc as you need to know clearly about which point you are rotating or scaling and that might move as you transform things [remember you can transform! a point too...]

      hmm but my @pt 1, is the origin for rotation..and I scale form the point @pt1....so the point should never move....when I do them individually the component stays where it should...@pt1 doesnt change, I don't know what would make it want to translate to a a dif point. I do make sure to do the scale first, because that stretches in the X direction, so I do the scale before it gets rotated. So i see why order is important, but not why it translates my instance :S

      posted in Developers' Forum
      K
      kdasilva
    • RE: Transformation Troubles

      oops I found a big mistake, that improved and made things worse...I realized I WAS clearing @pt1 and @pt2 with a reset call that was happening. So it was working all with zeros......however now that i removed that my arrows are going off in strange directions and rotating in ways i don't understand! I cuold really use some help from a transformation guru~


      After some testing I have a major question for my own understanding. How do multiple transformations work?? My scale will scale if its by itself, but as soon as I do two transformation (iescale with a rotation) the it starts to move somewhere else. From what I read I am guessing this has something to do with the transformation matrix ...but I can't seem to figure out how to navigate it.

      Is there a way to isolate each transformation? so they don't interact? (the !move worked for my last problem but not here..)

      cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • Transformation Troubles

      Hello again my new favourite forum~

      I come seeking guidance on working with transformations...

      I have a component, that gets placed upon the first click, a view line is then drawn which the user then uses to infer what angle, and what x scale to apply to the component (a big arrow in this case)

      so far:
      first click (gets placed)
      first click

      drawing the line
      drawing line

      second click (where my transformation skills fail me)
      second click

      As those show, my scale vector scales to the right size but my rotation just flips it onto its side. I tested each one independently, and they both moved the arrow back to the origin

      Here is the method I used for the transformation:

      
      def onLButtonDown flags, x, y, view
       if @first_click
         if (@pt1.position.distance @pt2.position) > 0
          draw_the_line
          rotate_vector = Geom;;Vector3d.new 0,0,1
          point_vector = @pt2.position - @pt1.position
          rotate_angle = rotate_vector.angle_between point_vector
          rotate = Geom;;Transformation.rotation( @pt1.position, rotate_vector, rotate_angle )
          xscale = @@edge.length.to_f / 72.25
          xscale_transformation = Geom;;Transformation.scaling @pt1.position, xscale, 1, 1
          @insert_arrow1.move!(Geom;;Transformation.new(xscale_transformation))
          @insert_arrow1.transform!(Geom;;Transformation.new(rotate))
         end
       else
        @pt1.pick view, x, y
        newpt = Geom;;Transformation.new( @pt1.position )
        @insert_arrow1 = @@ents.add_instance( @@comp_def_viewArrow, newpt)
        @first_click = true
       end
      end
      
      

      The reason i used .move! and then .transform! is because if I used both as .move! it seemed the second transformation cancelled out the first one (it wouldn't be scaled) and if I used .transform! for the scale it started jumping away (like the problem recently resolved in my previous tool post)

      Essentially my two issues are: Not having the transformation jump back to the origin, and the rotation I cant seem to work it always just flips up onto its side.

      My knowledge of vectors is pretty poor, so that very well might be the source of my issue.

      Cheers,

      Korbin~

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved!!]onMouseMove show component instance

      no totally error free BUT..i just made it work by.....(drumroll)... changing .transform!() to .move!()

      I don't know why it worked...i just did it on a whim, but presto!

      thanks for all the help, this was driving me crazy...so much thesis to do, but I tend to obsess on things I cant solve.

      cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved!!]onMouseMove show component instance

      @tig said:

      @kdasilva said:

      @tig said:

      The code should move the instance with the cursor until you click then it stops.

      Thank you for continuing to help, and I did implement what you suggested however I still have my main problem which is that, although the code does move the instance with my cursor (or with my clicks in the more controlled testing) it does not move to where the cursor is.....however the transform! method is working it is not simply moving the instance to my cursor...it is moving it in some other weird direction, which I beleive I found out somewhat why in my previous post...however I don't know how to make it not do that 😞
      cheers,
      Korbin
      For example - assuming the component-instance is added and referenced as @instance

      
      > def onMouseMove(flags, x, y, view)
      >   return nil if not @instance ### only works when instance is set
      >   @ip.pick(view, x, y)
      >   if @ip != @ip1
      >     view.invalidate if( @ip.display? or @ip1.display? )
      >     @ip1.copy!(@ip)
      >     view.tooltip=@ip1.tooltip
      >     @instance.transform!(Geom;;Transformation.new(@ip1.position))
      >   end
      > end
      > 
      

      Later

      
      > def onLButtonDown(flags, x, y, view)
      >   return nil if not @instance
      >   @ip1.pick(view, x, y)
      >   if @ip1.valid?
      >     @instance.transform!(Geom;;Transformation.new(@ip1.position))
      >     @instance=nil ### un-sets instance
      >   end
      > end
      

      Then reset @instance to another new instance... 🤓

      wow so i was definitely missing a few things...alas put your code in directly, changed the necessary variable names, ...but same result 😞

      When I creep my mouse onto the screen, it will move to my mouse for the very first move...but any subsequent move sends the instance off rapidly in a another direction...is this just a problem for me??

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved!!]onMouseMove show component instance

      @tig said:

      The code should move the instance with the cursor until you click then it stops.

      Thank you for continuing to help, and I did implement what you suggested however I still have my main problem which is that, although the code does move the instance with my cursor (or with my clicks in the more controlled testing) it does not move to where the cursor is.....however the transform! method is working it is not simply moving the instance to my cursor...it is moving it in some other weird direction, which I beleive I found out somewhat why in my previous post...however I don't know how to make it not do that 😞

      cheers,
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved] Scale to length

      Ah i see the to_f worked perfectly, for some reason I was trying to convert it into feet with decimal places last night, not sure why....my brain was not quite as sharp after about 15 hours of coding/writing last night~

      cheers
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • [solved] Scale to length

      hello again, sorry for asking another question while my other is still not resolved~ but I had another question that has come up from another step of my tool.

      Can I use a length to create a scale transformation? Basically I am trying to scale a component to the length of the line? scale transformation requires a scale factor....

      I was thinking I could take then length of the line, ie 12, and then divide it by the length of the component, ie 3, to get a scaling factor of 4? However I got stumped on this part due to units...my component measured 6' 1/4" not sure how I put this value into a variable I can use to divide my line length...

      is their an easier way? and if not...could someone enlighten me on how to use the units? (I guess I could just switch the model to mm, but I would rather not as its not intuitive for community members at the urban design scale [my audience])

      thanks again!

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved!!]onMouseMove show component instance

      hmmm i have been testing away and:

      (this is just the one relevant methods)

      
      	def onLButtonDown flags, x, y, view
      		@pt1.pick view, x, y
      		newpt = Geom;;Transformation.new( @pt1.position )
      		puts newpt.origin
      		@insert_tree_1.transform!( newpt )
      		reset
      	end
      
      

      (reset is just @pt1.clear)

      So from my testing I am pretty sure the pick is working because when I just had a new tree put down for every new click it went where it was supposed to. So I started testing the above code, so i could keep better track of what was going on then with the onMouseMove (when it was in onMouseMove it spazzed off really fast is some direction). From the above code I could tell that the first click I do (my tree starts at the origin) it successfully translates to the proper position, however each subsequent click something weird goes on.

      I clicked on the red axis, the tree went to the right spot, I then click on approximately the same distance down the green axis and the tree translated to from what I could tell the intersect of going straight out from the point on the red and the green (my math fails me off the top of my, inst that the the sum of the two points?)...some sort of math went on..

      I tried adding

      
      @insert_tree_1.transform!( [0,0,0] )
      
      

      right before the translation in hopes that it would reset the tree position but I got the same result. So i am lead to believe its a problem with my @pt1? is it perhaps not getting reset? (i use .clear after each click)......

      This is as far as my investigating could get me 😞

      If anyone can shed any light for me it would be appreciated.

      *edit
      Im pretty sure now that it is to do with the my instance variable and the translation.....from what I can tell it is adding its current location before it translates itself...thus why the first translation works because its adding 0,0,0. ....could I subtract the current location from the transformation to cancel this out?? I think I'm just using the method wrong...

      Cheers,
      Korbin

      posted in Developers' Forum
      K
      kdasilva
    • RE: [solved!!]onMouseMove show component instance

      @tig said:

      I just suggested adding the instance at the ORIGIN as it was simple - you could add it onto the current cursor position.
      Your code is missing some important parts... like how the instance is added and referred to, and the closing 'end' to the 'onLButtonDown' method...
      The .transform! method should work...
      There is also a 'translation' transformation where you find the current instance.position and the vector to the current cursor.position and slide the instance along it BUT it should work as well as the 'transform!.........

      I didn't post all the code sorry I thought it would be simpler if I just put those methods in.

      The things you referred to are in the code. the tree appears at the origin, then as I move my mouse it gets transformed but in some other direction, and farther and farther away quite rapidly...

      This is what I have been using to test it with:
      (I know I might be using class variables when I could be using instance...but that shouldn't be the problem)

      
      class AddTree1
      	@@model = Sketchup.active_model
      	@@ents = @@model.entities
      
      # Initialize the input point upon start
      def activate
       dl = @@model.definitions
       file_path = Sketchup.find_support_file "KorbinTest/components/Tree_2D_Schematic_Sparse_12_.skp", "Plugins"
       @pt1 = Sketchup;;InputPoint.new
       @@comp_def_tree1 = dl.load file_path
       @insert_tree_1 = @@ents.add_instance( @@comp_def_tree1, Geom;;Transformation.new)
       @clicked = false
      end
      
      
      def onMouseMove flags, x, y, view
       if @clicked == false
        @pt1.pick view, x, y
        @newpt = Geom;;Transformation.new( @pt1.position )
        @insert_tree_1.transform!( @newpt )
       end
      end
      
      def onLButtonDown flags, x, y, view
       @pt1.pick view, x, y
       @newpt = Geom;;Transformation.new( @pt1.position )
       @insert_tree_1.transform!( @newpt )
       @clicked = true
       reset
      end
      
      def reset
       @pt1.clear
      end
      
      def onCancel flags, view
       reset
      end
      	
      end
      
      Sketchup.active_model.select_tool AddTree1.new
      
      
      posted in Developers' Forum
      K
      kdasilva
    • 1 / 1