• Login
sketchucation logo sketchucation
  • Login
🤑 30% Off | Artisan 2 on sale until April 30th Buy Now

Simple Extension for Mac

Scheduled Pinned Locked Moved Developers' Forum
25 Posts 6 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    Dan Rathbun
    last edited by 26 Nov 2013, 15:03

    @olilej said:

    I've been playing around with C Extension recently and I would like to know how if there is an equivalent of is_a? ruby function in C level.

    If you have the CHM... you can click on the method description, and the C source will popup:
    (Also works for online version , but the source link must be clicked directly, and is only visible when the mouse is hovering over the method description.)

    Object_kind_of.png

    💭

    I'm not here much anymore.

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 26 Nov 2013, 15:05

      So it looks like there are some macros defined in C, to make life easier ... CLASS_OF(), RCLASS_SUPER(), etc.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 27 Nov 2013, 04:33

        • Pragmatic Programmer: Extending Ruby 1.9

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • O Offline
          olilej
          last edited by 27 Nov 2013, 17:25

          Great, my goal is to make sure I'm dealing with a Entity in order to access its attributes.

          Here is the code I've come up with.

          VALUE result = rb_obj_is_kind_of(obj, rb_path2class("Sketchup;;Entity"));
          if (Qtrue == result){
          	VALUE rval = rb_funcall(obj, rb_intern("get_attribute"), 2, rb_str_new2("dynamic_attributes"), rb_str_new2("..."));
          	...
          }
          
          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 27 Nov 2013, 20:21

            Only Sketchup::ComponentDefinition and Sketchup::ComponentInstance will have dictionaries with that special name.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • 1
            • 2
            • 2 / 2
            2 / 2
            • First post
              24/25
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement