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

    Posts

    Recent Best Controversial
    • RE: Pushpull/move a component instance's face

      Damn you Tig!! Because of your ingenious solution I have to rethink my code πŸ˜› πŸ˜„

      BUT that's a good thing since in the end it'll be efficient. πŸ‘

      On semi-related note... when rotating a component on Z axis from center 180deg(basically mimicing flip along blue, i think πŸ˜•) the left becomes the right and the right becomes the left, anyway to change face.normal?

      Using the upper image as an example, if I add 2 instances of that component and flip one so that the side with the 3 blue faces face each other the unflipped components ahs the blue faces as 'top faces' and the flipped faces has them as 'bottom faces' which is true BUT it makes it harder to 'find' those faces. So i'd like to be able to flip the component but keep the original direction of the faces... amke sense??

      I came up with a solution but it seems like so much work!

      posted in Developers' Forum
      F
      Frankn
    • RE: Pushpull/move a component instance's face

      I'm able to manipulate faces as I wish by determining their orientation BUT how can I identify specific faces that I want to manipulate when there are multiple faces pointing in the same direction? For example if I wanted to only pushpull the middle blue face in the picture in my op?

      I tried naming the faces like this

      face.name="face 1"
      

      but that didn't work.

      Any ideas?

      Thanks,
      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Pushpull/move a component instance's face

      @tig said:

      OR say you want to only pushpull faces that look 'up', even if they are 'angled'...
      if face.normal.z>0
      or to they look to the right, somewhat...
      if face.normal.x>0

      there are many ways to slice-and-dice this...

      That totally makes sense but I didn't even realise I could do it that way... 😳

      Thanks again!
      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Pushpull/move a component instance's face

      Thanks Tig,

      Took a little while for me to figure out what Vector3d value referenced what face but once I figured that out I was able to test which face was facing is which direction...

      left=Geom::Vector3d.new(-1,0,0)
      right=Geom::Vector3d.new(1,0,0)
      front=Geom::Vector3d.new(0,-1,0)
      back=Geom::Vector3d.new(0,1,0)
      up=Geom::Vector3d.new(0,0,1)
      down=Geom::Vector3d.new(0,0,-1)

      Then I can test to see which faces I need to pushpull. I'm sure there are more efficient ways to doing this but for me and for now with a relatively simple model it works and I'm happy. β˜€

      posted in Developers' Forum
      F
      Frankn
    • RE: Pushpull/move a component instance's face

      @tig said:

      You are adding the faces each as an array. so they are each inside a one element array [same with the edges!]
      faces.push([e]) should be faces.push(e)
      or even faces << e
      i.e. NO enclosing **[]**
      then it'll work !

      Another way would be something like the slightly faster:
      faces=array[1][0].grep(Sketchup::Face)
      you don't actually explain what ' array' is πŸ˜•

      Thanks you sir that works perfect! I haven't tried your second suggestion yet and I really need to find the time to read up on 'grep' seems I see you 'pros' using it more and more.

      array is somewhat of a 'test' array which includes different information in regards to the individual subcomponents and I've been playing around with the info I add to it, which is why I didn't go into detail as to what holds.

      On a related note, is there an 'easy' way to identify which face is which? Right now I just do it through trial and error changing the value X in faces[X].pushpull 10 till I find the ones I want to pushpull.

      posted in Developers' Forum
      F
      Frankn
    • Pushpull/move a component instance's face

      How can the pushpull tool be replicated with the API?

      If I want to pushpull/move the blue highlighed faces, which are a subcomponent of a component(only the subcomponent is), in the attached picture in the Z dircetion how would I go about doing that?

      I've tried a few things but the results aren't good. πŸ˜•
      Here's what I've tried so far, array[1][0] is the subcomponent of the parent component.

      
      # retrieve faces and edges
      edges=[]
      faces=[]
      array[1][0].entities.each{|e|
         if e.is_a?(Sketchup;;Face)
            faces.push([e])
         end
      				
         if e.is_a?(Sketchup;;Edge)
           edges.push([e])
         end
      }
      
      

      this doesn't give the desired result, it doesn't move the face, more like just a single edge of the face and also 'copies' the subcomponent to the model origin.

      
      t=Geom;;Transformation.translation [10,0,0]
      entities.transform_entities(t, faces[0])
      
      

      I was hoping it would as simple as this but this doesn't work either, I get this error
      Error: #<NoMethodError: undefined method `pushpull' for [#Sketchup::Face:0xce78a90]:Array>

      
      faces[0].pushpull 1
      
      

      Thanks,
      Frank


      example.jpg

      posted in Developers' Forum
      F
      Frankn
    • RE: Retrieving parent definition

      @chris fullmer said:

      Frankn, just to clarify for myself, but you really want only components that have sub-components in them? or is it that you want a list of definitions whose instances are NOT sub-components?

      Hey Chris, I wanted to be able to find the parent definition of components with subcomponets that aren't in the model but still in the definition list. Hope that makes sense... but if it doesn't, basically the 2nd code that Tig shared is what I wanted to accomplish.

      posted in Developers' Forum
      F
      Frankn
    • RE: Retrieving parent definition

      Thanks for taking the time to reply,

      @Chris, I've never heard of grep before, which isn't all that surprising since I'm still very much a newbie to all this. I'll have to look into it and see how helpful it can be in certain instances. I tried to run your code but it only returns instances... I'm thinking there's something you might of left out which is cool it'll give me something to play with and see if I can figure it out on my own which is how I seem to learn the best. πŸ˜‰

      @Dan, thanks for the simple solution which works great! Again, you're using grep which I have no clue of what it does but this line of code I'm sure will be helpful in understanding it.

      @Tig, Thanks for the more detailed code, it works just as desribed and does exactly what I need it to do. I'll study the code later on to try and fully understand what's going on there. One question regarding your code, any reason or advantage to using << instead of .push()?

      It's always interesting to see that there are many ways to accomplish the same task. Thanks for your time guys.

      One suggestion if I may do so, maybe this should be added to the code snippets thread? Asking is always my last resort so I'm getting pretty good at searching for answers and I couldn't for the life of me find anything pertaining to this. 😳

      Frank

      posted in Developers' Forum
      F
      Frankn
    • Retrieving parent definition

      I can go through the definition list and get an array of all the components but I'd like to get an array of only the parent components. How can the parent definition of a component with subcomponents be retrieved from the definition list if the definition doesn't have an instance?

      Sorry if this has been asked before but I can't seem to find anything searching the forum.

      Thanks,
      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Hightlight/select component with mouse over

      WOW! Thanks sdmitch!!

      That's way over my pay grade, Damn!

      I tested it and it works great, though I must admit I'll have to study the code a lot to figure out how you did it and even then I'm not sure I'll get it. πŸ˜„

      posted in Developers' Forum
      F
      Frankn
    • RE: Hightlight/select component with mouse over

      Thanks sdmitch,

      I kinda figured that part out but what I can't figure out is how can I have the mouse input point (@ip1) find the individual corners?

      @ip1.position returns the screen coords but I can get it to return the bounding box coords. If the cursor was over the left, back, bottom corner (corner(2)) I want it to return corner(2) and not where corner 2 is located. Does that make any sense?

      posted in Developers' Forum
      F
      Frankn
    • RE: Hightlight/select component with mouse over

      Here's another update...

      After selecting the component on a mouse over/hover I wanted to retrieve a few bits of information, component name, dimensions and which corner of the bounding box the cursor is pointing at. As per my previous update I was able to get the name and now I figured out how the get the dimensions... here's the code snippet.

      
      component_definition=selected_comp.definition
      component_height=bounds.depth
      component_depth=bounds.width
      component_width=bounds.height
      component_dimensions=[component_height, component_width, component_depth]
      
      

      I then send the info to the VCB.

      Now I need to figure out the bounding box corners and component orientation... wish me luck! πŸ˜• πŸ˜„ If anyone have ideas please share them... πŸ˜„

      p.s. hope the mods don't mind me updating my own post/question but I figure maybe the information will come in handy for another newb trying to do something similiar. I know for you advanced ruby guys/gals this is trvial but for a newb like me finding and then understanding how to implement this stuff is not easy.

      Let me know if you'd rather I stop.

      posted in Developers' Forum
      F
      Frankn
    • RE: Hightlight/select component with mouse over

      Ok so I found how to get the name while hovering over a component... might not be the best way but it works... πŸ˜„

      
      select_comp=view.pick_helper
      select_comp.do_pick x,y
      selected_comp=select_comp.best_picked	    
       	    
      if selected_comp and selected_comp.is_a?(Sketchup;;ComponentInstance)
      selected_comp_name=selected_comp.definition.name
      Sketchup.active_model.selection.add selected_comp
      else
      Sketchup.active_model.selection.clear
      end  
      
      

      Still need to figure out how to get the bounding box to appear and retrieve it's coordinates. And also how to limit drawing a line only in the X and Y axis. πŸ˜•

      EDIT: Updated code to add selecting the component/bounding box.

      posted in Developers' Forum
      F
      Frankn
    • Hightlight/select component with mouse over

      I'm working on a custom tool and I just about have everything I want working, I'm working/modifying the linetool.rb file. One thing I'd like to add as a function is having the mouse select/highlight the bounding box just like the 'move' tool does and then get bounding box coords for the selected/highlighted component.

      As a second part, I'd like to limit drawing a line in the x,y planes, again something like hittong 'shift. when using the 'tape measure' tool but without having to use shift.

      Thanks,
      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Scaling a component with subcomponents

      Hey Fredo6,
      I actually mentionned you plugin in my other post and how I was trying to figure out how you did it. Only problem is you're a ruby/sketchup god and I'm more of a peasant. πŸ˜„

      Thanks to Chris, I now know that what I'm trying to accomplish is called parametric modeling, learn something new everyday πŸ˜„. So I did a search for that and came up with this file parametric.rb (attached) and a couple of interesting websites, though I haven't had a chance to go through them so I apologize if they aren't that good.

      http://drivingdimensions.com/SketchUp/FAQ/
      http://www.sketchup.com/intl/en/download/rubyscripts.html

      [EDIT: attachment removed by admin]

      posted in Developers' Forum
      F
      Frankn
    • RE: Scaling a component with subcomponents

      Thanks Tig,

      The move tool works fine for a 'simple' cabinet but once doors, drawers and drawer boxes are added it quickly becomes cubersome, if not impossible to do. I was hoping that it was a simple matter of modifying the scale tool or getting DCs figuered out but it seems like it's way more complicated then that, for a simplton like me anyways. πŸ˜‰

      Yes that's exactly right Chris... there's a lot going on in something as 'simple' as a cabinet, I'm surprised I made it this far with this plugin. πŸ˜„

      Thanks for the ideas and insight, hopefully I can come up with something.

      posted in Developers' Forum
      F
      Frankn
    • RE: Scaling a component with subcomponents

      Well I followed your advice and played with DC interface a little more and paid much more attention to how it works... so I set a value lenx and found this code snipet which modifies it...

      
      cab_instance = Sketchup.active_model.entities[0]
      cab_definition = cab_instance.definition
      ad = cab_definition.attribute_dictionary "dynamic_attributes"
      ad["_lenx_"] = '10' 
      $dc_observers.get_latest_class.redraw_with_undo(cab_instance)
      
      

      BUT it actually acts in the same way as scaling does but is more complicated lol! Talk about going full circle. And yeah there aren't too many examples of controlling DCs through ruby.

      I'll keep trying out some things and see what I can figure out.

      posted in Developers' Forum
      F
      Frankn
    • RE: Scaling a component with subcomponents

      @chris fullmer said:

      But how do you envision it working otherwise? If you scale a component, it scales everything inside it. What were you expecting it to do?

      Yeah, scaling works fine for the 'outer' dimensions, meaning that if a cabient is 20"w x 20"d x 20"h and the cabinet carcass stock is 5/8" thick and I change the height to 10", which is scaling the by 0.5, the height of the cabinet changes to 10" which is great but the thinknes of 5/8" also gets scaled down by 0.5 and then becomes 5/16". I'm having a hard time explaining what I mean so I included a picture.

      dim1.jpg

      @unknownuser said:

      And yes, this will be much more work then getting an actual DC to work. Because you're reprogramming a lot of stuff - reinventing the wheel if you will. the only reason to reinvent the wheel should be if the wheel isn't working for your needs. In other words, if DC's do what you need, then don't remake your own version of DC's.

      But if you need different functionality, or if you just want a complex program to write for fun, then go for it!

      DCs do some of what I want and can probably do more, honestly I didn't play around with it much since yes in part I'm just trying to learn new stuff and kind of make a one stop shop plugin. Not all users would want to or even know how to use DCs so in that sense I want to 'simplify' the process of editing a built cabinet.

      Which brings me back to my original post/question, where can I find more info or examples of how to manipulate components/create DCs through ruby?

      Frank

      posted in Developers' Forum
      F
      Frankn
    • RE: Scaling a component with subcomponents

      Thanks, again, for your reply Chris.

      Man this is turning out to be more complicated then I first thought! But then again I've said that about everything about my plugin so far. πŸ˜‰

      What you're describing to do sounds a lot like what DCs do, no? Example, resizing the height of a cabinet would only stretch the sides, back and any other components like doors or drawers and then move the othe components to match the height. Seems like scaling is a lot mor 'work' then trying to get DCs working... but again this is all new to me and I might be way out in left field here.

      I did find a plugin that does what I'd like to do and that is freescale from Freedo. I'm trying to follow along in the ruby code as to how he goes about doing what his plugin calls 'Box Stretching' but Freedo is a ruby god and so far it hasn't been easy to figure out the code. πŸ˜„

      posted in Developers' Forum
      F
      Frankn
    • Scaling a component with subcomponents

      So after starting a topic on DCs and creating only to find out that's more then likely not what I need to do. Topic found here...
      http://sketchucation.com/forums/viewtopic.php?f=180&t=48697

      I started looking into scaling.. which works, somewhat.

      Here's the code I've been playing with...

      model = Sketchup.active_model
      entities = model.active_entities
      ss = model.selection
      ents = Sketchup.active_model.entities
      t = Geom;;Transformation.scaling 1,1,0.5
      ents.transform_entities t, ss
      

      This works BUT it also scales the subcomponents. I'd like to be able to scale or manipulate those individually if needed.

      Basically my plugin creates cabinets and I'd like to be able to change the size of any given value once the component is created. I am using a web dialog and everything works but I'd really liketo integrate this into my plugin. I know I can do it with DCs but again I'd like to be able to do this directly from my plugin.

      Hope that gives a clearer understanding of what I'm trying to accomplish.

      Thanks,
      Frank

      posted in Developers' Forum
      F
      Frankn
    • 1 / 1