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

    Posts

    Recent Best Controversial
    • Surface area of a component/group made up of groups

      I want to get the total external surface area of a component or group that is made up of groups and components that are butted next to each other. So in effect the total surface area of the outer shell of the component not just the surface area of each of the groups/components added together. I appreciate that I could actually 'outer shell' the component and then just get the area of all the resultant faces and add them up - this would work but would slow down the process considerably when working with lots of parts.

      Is there a way of doing this without actually changing the model at all and therefore that doesn't slow down the process too much or does it all start to get quite complex?

      Thanks

      posted in Developers' Forum
      W
      wawmsey7
    • Call C++ from ruby in Sketchup

      I'm trying to enable panel optimisation in my plugin and the code to do this properly is exceedingly complex so I've been trying to track down some code that already exists for this... I run a mac and most libraries to run this function work with dll which is no good, but I have managed to track down one that should work with c++ ...

      Link Preview Image
      Cut 2D X - wood, glass, metal, sheet, paper, cutting and nesting library

      Automation component (library) for rectangular (2D) nesting and cutting optimization of glass, wood, metal, paper, sheets. Can be used with Delphi, Visual Basic, C#, Java, Excel, VC++ etc.

      favicon

      (optimalprograms.com)

      So my question is... If this does work (i've sent an email to the company to enquire), can I run / access the c++ file / function from within ruby and obtain the results in ruby...?

      would really appreciate it if anyone has any ideas on this or in general the whole panel optimisation / 2d bin backing / 2d stock cutting problem thing???

      Thanks

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Webdialog - getting started?

      thanks for the help, that's a really useful reference!

      posted in Developers' Forum
      W
      wawmsey7
    • Webdialog - getting started?

      I'm wanting to make a basic webdialog for my plugin whereby the webdialog is simply used to set the variables in my script. I have basic knowledge of html, css and javascript so for the moment have managed to scramble together a basic form for my inputs.

      So for example the form goes:

      [pre:twxh754o]height : (input box)
      width : (input box)
      depth : (input box)

      (submit button)[/pre:twxh754o]

      (* I'm aware that it's easy enough to do this example using the UI.inputbox method but this is just a basic example so I can begin to wrap my head around using the webdialog!)

      So what would be the best way to get the data that the user inputs into the form and asign it to variables once they press the 'submit button'?

      Thanks in advance for your help,
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Load a vismat / vray material into sketchup using ruby code?

      I added a vismat material into the model and looked inside the material attribute dictionaries and found one dictionary that had one key "V-Ray for SketchUp Material Attribute"... This presumably holds all of the data vray needs for the material? the value for this is a really long a complicated load of stuff which begins....

      <Assets>
      <Asset renderer="vray" url="/Wood_02/Reflection/transparency_texture/TexFresnel" type="texture" layout="">
      <plugin>
      <vrayplugin version="7" type="texture" name="TexFresnel">
      <parameters>
      <parameter handler="default" listType="none" type="acolor texture" name="black_color_tex" label="Perpendicular Texture">
      <value></value>
      </parameter>
      <parameter handler="default" listType="none" type="acolor" name="black_color" label="Perpendicular">
      <value>
      <r>1.000000</r>
      <g>1.000000</g>
      <b>1.000000</b>
      </value>
      </parameter>
      <parameter handler="default" listType="none" type="bool" name="use_multiplier_as_exponent" label="Multiplier as exponent">
      <value>1</value>
      </parameter>
      <parameter handler="default" listType="none" type="float texture" name="refract_ior_tex" label="Refract IOR Texture">
      <value></value>
      </parameter>
      <parameter handler="default" listType="none" type="bool" name="invert" label="invert">
      <value>0</value>
      </parameter>
      <parameter handler="default" listType="none" type="float" name="refract_ior" label="Refract IOR">
      <value>1.550000</value>
      </parameter>
      <parameter handler="default" listType="none" type="float" name="fresnel_ior" label="IOR">
      <value>2.500000</value>
      </parameter>
      <parameter handler="default" listType="none" type="float" name="black_color_tex_mult" label="Perpendicular Texture Multiplier">
      <value>1.000000</value>
      

      and goes on... bla bla bla....

      so i guess if I put all this into the material in my code then it will behave like this vismat material when rendered??

      posted in V-Ray
      W
      wawmsey7
    • Load a vismat / vray material into sketchup using ruby code?

      Is it possible to load a vismat material into sketchup via the ruby script. So in this case i have written a script to draw some stuff and I now want to apply a saved vray material (.vismat) to it's faces as a part of the script so that it is all ready for rendering.
      Is this possible?

      If not, then what would be the best way to replace the material that is already mapped onto the faces how I want, with a vismat that has the same texture, so that the texture stays in the same place?

      Thanks for your help in advance,
      Matt

      posted in V-Ray render plugins extensions
      W
      wawmsey7
    • Load a vismat / vray material into sketchup??

      Is it possible to load a vismat material into sketchup via the ruby script. So in this case i have written a script to draw some stuff and I now want to apply a saved vray material (.vismat) to it's faces as a part of the script so that it is all ready for rendering.
      Is this possible?
      Thanks for your help,

      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Textures in model slow down ruby?

      No, I'm adding materials the normal way. Adding the materials isn't the problem. I was having a problem whereby adding component definitions is slower if I simply have materials with textures in the model, and the the more there are the slower it goes... but i've managed to nullify this problem by writing my code better so that I only define each component that I need to load for my scripts once.

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Textures in model slow down ruby?

      I do use vray, but it was disabled throughout all of this... just to be on the safe side!

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Textures in model slow down ruby?

      I've worked out that textures in the model only make the script run slowly when it is pulling/importing the component definitions into the model like so...

      shelfpin = Sketchup.active_model.definitions.load ("filename")

      and in one of my scripts I had this as part of a defined function which I was looping 50+ times to cut shelf holes and add a shelf pin for various positions on a panel - so was in affect importing the shelf pin component 50+ times completely unnecessarily.

      So as soon as I took out this out of the code completely (given that the component is already loaded in the model) and ran the same code again, it ran at the same fast speed as it does when there isn't any textures in the model!

      So my solution is to run the code to load the components needed for all my scripts once and then it's all done only once and I'm free to run any of my scripts after it.

      However it would be easier if I could have code before the code for loading the component to check if it's already loaded or not into the model and then load it if it's not already there? Is that do-able?

      **the following code just tagged on the end seemed to work fine

         magd = Sketchup.active_model.definitions.load (file) if magd.class != Sketchup;;ComponentDefinition
      

      theres probably a tonne of ways to do this but that seemed to do the job

      Thanks

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Textures in model slow down ruby?

      thanks, yes I am wrapping all the code with the start and end operation commands

      
      @model.start_operation('Leg',true)
      
      ...code...
      
      @model.commit_operation      
      
      

      I am using a new 15" macbook pro OSX yosemite with the latest sketchup pro version

      this is one of the smaller textures i am using...
      (the others exceeded the pixel limit for uploading to sketchucation (3000x2000-ish))


      Estate_Harvest_Oak21_extractedTex2366 copy.jpg

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Textures in model slow down ruby?

      After a bit of trial and error I have found that the problem only occurs on scripts where I am pulling an external component into the model as part of the script, like this...

      
        shelfpin = Sketchup.active_model.definitions.load ("filename")
        ents.add_instance shelfpin, (Geom;;Transformation.new [posx,posy,posz])
      
      

      doing this works fine when no textures are loaded in the model and runs just as fast as the other scripts, however if there are textured materials in the model (as described previously) then it really slows down the script?? it doesn't slow down any other scripts...

      The components I am pulling in don't have any materials already applied...

      Anyone got any ideas? Is there a way around this??

      Thanks again
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • Textures in model slow down ruby?

      Hi,

      I've written various script for drawing various parts of a cabinet, so just generally drawing shapes pushpull-ing followme etc... I'm finding that that scripts all run really nice and fast- for example one of them completes in 0.06 seconds! Which is perfect... However as soon as I bring a texture into the model, not into the script just import it into the model not even applied to anything. Then when I run the script exactly the same as before it takes 0.5 seconds to complete the same tasks!! Which is nearly 10 times as long to do the same things, the only difference being that there is a texture loaded in the materials box. The texture in this case isn't particularly large - 600kb JPEG.

      Is there anything I could be doing wrong or is there a setting to change that could help this? Or is this just how it goes??
      ('use maximum texture size' in openGL settings is set to off)

      Thanks for your help
      Matt

      ** just tried adding 3 materials to the material toolbar all with textures of about 1mb each and the same script now takes 7 seconds to complete!!! Surely this isn't just how it is??

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Geometry in which group after boolean subtract??

      **my own stupidity - the subtract was done within a defined method so just couldn't access it outside it..

      putting @ in front solved it... @result

      posted in Developers' Forum
      W
      wawmsey7
    • Geometry in which group after boolean subtract??

      If you have two groups and do a boolean subtract on one to the other then what group does the resulting geometry end up in??

      so for example....

      result = group2.subtract(group1)
      The group isn't called 'result' because if I do 'result.class' I get 'NilClass' and neither is it called group1 or group2 (original groups) because if I type these in I get a reference to a deleted entity - #<Deleted Entity:0x7fd36ac90d70>. So how do I get a reference to this new resultant group??

      Thanks
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • RE: How to pushpull through a 3d object?

      Thanks TIG

      I only defined 9 edges because the plan was to use them later in the code - just managed to hit a stumbling block first!

      the method including the flatten method seems to help but not solve the problem completely. I tried the grouping and then exploding method that you explained but didn't manage to get this to work. Also I didn't really understand why it might work?

      After a bit of trial and error this is what I'm finding....

      I can make a face that isn't connected to any other geometry from either points or edges - no problem.

      However, if I want to draw a shape onto another existing face and then be able to reference the face bound by its edges (for example if I either wanted to pushpull it or use a followme method) then this only seems to work if I made the face using points rather than edges...?

      So if I ask it to make a face onto an existing face using an array of edges and ask for the face class (puts face.class) i get NilClass. However, I had made the face using points instead and then ask for the class i get 'Sketchup::Face' - which means i now have a face to reference for pushpull etc...

      This is fine for making things that are fairly simple and can practically be drawn using just points for reference, but it isn't practical where curves or radius's are involved and therefore you need to use edges in these situations...

      I hope that this makes sense or am I missing something?

      If I could turn an array of edges into an array of points then in theory that would work, but I don't know how to do that?

      Any ideas??

      Thanks again
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • How to pushpull through a 3d object?

      Another newbies ruby question...

      I quite simply want to pushpull a 2d shape/face through a 3d object just as you would when normally modelling in sketchup to, say just cut a hole through a cube...

      my code is for pushpull-ing a radius on a cubes corner

      code atm is...

      height=6.cm
      depth=2.cm
      length=100.cm
      edge_round=0.5.cm
      corner_round=2.5.cm
      
       model = Sketchup.active_model
       entities = model.active_entities
       objgroup=entities.add_group()
       usents=objgroup.entities
      
      face=usents.add_face([0,0,0],[length,0,0],[length,depth,0],[0,depth,0])
      face.pushpull(-height)
      
      e1 = usents.add_edges [0,0,0],[0,0,height-corner_round]
      e2 = usents.add_arc [corner_round,0,height-corner_round], [-1,0,0], [0,1,0], corner_round, 0.degrees, 90.degrees
      e3 = usents.add_edges [corner_round,0,height],[length-corner_round,0,height]
      e4 = usents.add_arc [length-corner_round,0,height-corner_round], [-1,0,0], [0,1,0], corner_round, 90.degrees, 180.degrees
      e5 = usents.add_edges [length,0,0],[length,0,height-corner_round]
      
      e6 = usents.add_edges [0,0,height-corner_round],[0,0,height]
      e7 = usents.add_edges [0,0,height],[corner_round,0,height]
      e8 = usents.add_edges [length,0,height],[length-corner_round,0,height]
      e9 = usents.add_edges [length,0,height],[length,0,height-corner_round]
      
      cface1=usents.add_face(e2+e6+e7)
      cface1.pushpull(-depth)
      

      the code is fine right up the the final pushpull line where it says...

      Error: #<NoMethodError: undefined method pushpull' for nil:NilClass> <main>:in <main>'
      SketchUp:1:in `eval'

      so i presume that this means it can't find the face i'm talking about?

      can anyone see why this isn't working?

      thanks again in advance
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Add_face from edges??

      thanks again for your help - that makes a lot more sense!

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Add_face from edges??

      Thanks.

      Just another quick one...

      I'm also struggling to make a simple rotation on an edge

      my code atm is...

       model = Sketchup.active_model
       entities = model.active_entities
      edge1 = entities.add_edges [0,0,0], [0,10,0]
      
      tr = Geom;;Transformation.rotation([0,0,0],[0,1,0],40.degrees)
      edge1.transform!(tr)
      
      

      again the edge draws fine but my rotation code throws up an error!

      anyone got any ideas?

      Thanks again
      Matt

      posted in Developers' Forum
      W
      wawmsey7
    • RE: Add_face from edges??

      thanks for your quick response, that worked perfectly!

      posted in Developers' Forum
      W
      wawmsey7
    • 1
    • 2
    • 1 / 2