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

    Posts

    Recent Best Controversial
    • RE: Entity ID and Materials!

      Also, I found that 2 materials CAN have the same name in a specific case: If you name one material Color_000 for example, it will be named like the Sketchup internal material of the same name: [Color_000]. (It seems that the SDK removes the brakets '[' and ']' when you get the name of an internal material with SUMaterialGetName()).

      posted in Developers' Forum
      M
      Marc477
    • RE: Entity ID and Materials!

      Ok thank you! I though 2 materials could have the same name.

      posted in Developers' Forum
      M
      Marc477
    • RE: Entity ID and Materials!

      I don't really understand how it is possible to have no persistent ID. In the skp file: how each face knows to which material it is bound? I supposed there is an ID saved with the face that tells which material is linked to the face.

      posted in Developers' Forum
      M
      Marc477
    • RE: Entity ID and Materials!

      Then how can I find: starting from a ruby API material: the corresponding SDK material ?

      posted in Developers' Forum
      M
      Marc477
    • Entity ID and Materials!

      I discovered that the entityID (for materials) is not the same when getting it from the Ruby API or the cpp SDK:

      Example (using the same material in both example)

      Ruby API

      
      //aMat is a material
      aMat.entityID
      //Returns 183 
      
      

      Cpp SDK

      
      //aMat is a SUMaterialRef
      int id;
      SUEntityRef entity = SUMaterialToEntity(aMat );
      SUEntityGetID(entity , &id);
      uint matID = (uint) id;
      //Returns 201
      
      

      I tested this using a custom attribute dict to make sure it is the same material in both cases, it seems that the material in the SDK has always an ID of +18, and if I don't cast it to a uint, its value is always negative.

      Why ? πŸ˜• πŸ˜’

      posted in Developers' Forum
      M
      Marc477
    • RE: SDK: Get Images data

      @tt_su said:

      Not that the API provides. You could extract to a temp file and read it.

      I'm not sure how I am supposed to extract the image to a file, if I cannot read its data.

      posted in Developers' Forum
      M
      Marc477
    • RE: SDK: Get Images data

      Any work around ?

      posted in Developers' Forum
      M
      Marc477
    • SDK: Get Images data

      In the Sketchup c++ SDK:

      What is the equivalent of SUTextureGetImageData for a SUImageRef? How can I access images pixel data?

      Thank you

      posted in Developers' Forum
      M
      Marc477
    • RE: Material is deleted when cloning

      Thank you, I fixed my problem by processing only materials used in the model:

      
      aMat = Sketchup.active_model.materials.current
      if aMat != nil and Sketchup.active_model.materials.include?(aMat)
         ...
      end
      
      
      
      posted in Developers' Forum
      M
      Marc477
    • Material is deleted when cloning

      Can someone explains why this happens ?

      
      test = Sketchup.active_model.materials.current
      #<Sketchup;;Material;0x8a19480>
      test2 = test.clone
      #<Deleted Entity;0x8a19278>
      
      

      I'd like to store a material in a class variable to use it later, if I do not clone, and the selection change, test will not contain the previous material I want, but the new one selected.

      Thank you πŸ˜„

      posted in Developers' Forum
      M
      Marc477
    • RE: Reading and drawing textures

      Thank you all, now I know how to do the first step (Reading texture data) but now I still wonder how to do the second step: drawing textures.

      As discussed above it doesn't seem to be possible to draw them in the viewport so I tought I could create a new window and display an image in it. I found that there is a WebDialog class that could be useful to create the new window, but now does anyone know how I can draw an image in those dialogs? I would like to avoid reloading the texture from Hard Drive everytime I refresh the image (since the image will be edited).

      I could load the texture only one time from the Hard Drive using ImageMajik (Thanks Dan), then update the "in memory" buffer directly and display it in the WebDialog. Is it possible to do that ? How do I draw in a web dialog an image loaded with ImageMajik ?

      posted in Developers' Forum
      M
      Marc477
    • RE: Reading and drawing textures

      @tt_su said:

      I'm confused - when you say "external tool" - you mean a custom Ruby Tool? Or some third party software?
      And "load in memory" you mean for reading the bitmap data? ... I guess you want the bitmap data - since you talked about this earlier.

      Yes sorry I meant "external third party library" and yes I want to read bitmap data.

      Ok so there is absolutely no way to read bitmap data of loaded textures in Sketchup!?

      Does that mean I need to double memory usage by reloading textures with an external library (probably OpenCv since I am working with a C extension).

      posted in Developers' Forum
      M
      Marc477
    • RE: Ruby c extension and Sketchup Objects

      Ok I found a way to achieve that. Here is an exemple with the Sketchup class Geom::Point3d

      static VALUE AddOne( VALUE self, VALUE p1 )
      {
          VALUE point;
          VALUE rbGeom, rbPoint3d;
          float x,y,z;
          
          //Convert to c float
          x = NUM2DBL(rb_funcall( p1, rb_intern( "x" ), 0 )) + 1;
          y = NUM2DBL(rb_funcall( p1, rb_intern( "y" ), 0 )) + 1;
          z = NUM2DBL(rb_funcall( p1, rb_intern( "z" ), 0 )) + 1;
          
          //Convert back to ruby VALUE
          rbGeom = rb_define_module( "Geom" );
          rbPoint3d = rb_define_class_under( rbGeom, "Point3d", rb_cObject );
          point = rb_funcall( rbPoint3d, rb_intern( "new" ), 3, rb_float_new(x), rb_float_new(y), rb_float_new(z) );
          return point;
      }
      

      This code takes a Point3d as parameter, adds one to each value and return the resulting Sketchup ruby object.

      posted in Developers' Forum
      M
      Marc477
    • Ruby c extension and Sketchup Objects

      I created a ruby c extension and I know how to use primitive types (int arrays...) as parameter in the functions I created in c.

      But is there any way to use a Sketchup object in a parameter? (like an entity) How can I decode the VALUE on the c side? Do I need a struct that fits the EXACT implementation of the object? Can I find that implementation?

      Thank you

      posted in Developers' Forum
      M
      Marc477
    • RE: Reading and drawing textures

      First, thank for all the fast answers.

      @dan rathbun said:

      The OpenGL draw functions are for use during custom Tools only, and they draw on the viewport, not in the model.

      Sorry, maybe my explanation was confusing, but what I want to do IS drawing in the viewport via a tool. I don't want to change the model and I don't want to change the .skp file.

      And how can I get texture's data loaded in SketchUp memory with an external tool ?
      Do you mean that I should write every texture with the TextureWriter and then load them with an external tool ?

      Thank you

      posted in Developers' Forum
      M
      Marc477
    • Reading and drawing textures

      Hi, I am new to the community and I just started a project. I read a lot on the Sketchup ruby API but there is one thing I really don't understand how it should be done.

      How am I supposed to access a texture data ? I'd like to get the value of a pixel in the texture linked to a specific material, but there is no data property in the texture class.

      Also, I'd like to draw a 2D texture, I saw the draw2d function but it seems to draw solid colors only.

      Thanks a lot! Any help would be great!

      posted in Developers' Forum
      M
      Marc477
    • 1 / 1