sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    My_forum_space

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    4 Posts 3 Posters 430 Views 3 Watching
    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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by honoluludesktop

      SU entities include basic geometry, like lines (or edges), and faces. A SU group is a unique collection of entities. An instance is a SU component that is one copy of a component definition. Groups have instances, and have ComponentDefinitions like ComponentInstances does.

      Images have component definitions as well, like Groups, SU treats them slightly different. You can see when you iterate model.definitions that you also get Group and Image definitions. ComponentDefinition has .image? and .group? that allows you to identify the type of component definition you are dealing with. This is important to check if you are processing all definitions in a model.

      The difference between one instance and another, is its transformation; its spatial location, scale, and rotation. Editing the entities in a component instance, edits the entities in all instances of that component. Groups are unique instances. Caveat: when you have multiple group instances of the same group definition and edit one via the ruby API they are not automatically made unique. You must call group.make_unique first - otherwise you edit all the group copies. Besides basic geometry (lines, surfaces, circles, arcs, etc.), entities include groups, and instances (component instances).

      The basic level of "collecting stuff" is an array of entities. The next level of collection is a group of entities, group.entities, and *instance.definition.entitites*. The final level is a collection of instance definitions, model.definition. Adding entities to the basic level is by entities.add_... where ... is a Sketchup::Entity (eg. entities.add_line).

      Before adding a Sketchup::Entity to entities, groups, instances, and components, one must be created, or identified. Identifying the basic entities in the existing model is first by identifying the current model, by model = Sketchup.active_model, and then its entities by entities = model.active_entities. Adding new entities to the collection of entities is as previously stated, entities.add_... where ... is a Sketchup::Entity.

      Adding entities to a new group, instance, or component, requires creating a new group, instance, or component by, entities.add_group, or [ruby:gcaqewus]entities.add_instance[/ruby:gcaqewus]. For example, [ruby:gcaqewus]my_group = entities.add_group[/ruby:gcaqewus] creates a new group, [ruby:gcaqewus]my_group[/ruby:gcaqewus]. Entities added to my_group are by [ruby:gcaqewus]my_group.entities.add_...[/ruby:gcaqewus], as noted above. The same sequence applies when adding entities to new instances.

      New definitions are created by identifying the current collection of definitions by [ruby:gcaqewus]definitions = model.definitions[/ruby:gcaqewus], then adding a new one by [ruby:gcaqewus]my_definition = definitions.add "Description_of_definition"[/ruby:gcaqewus]. Adding an instance to my_definition is by [ruby:gcaqewus]my_definition.entities.add_instance(my_instance.definition, my_instance.transformation)[/ruby:gcaqewus].

      The following code snippet changes a group into an instance, then adds the instance to a definition:

      #get current model
      model = Sketchup.active_model
      #get current entities array
      entities = model.active_entities
      #get model's definitions array
      definitions = model.definitions
      #add new empty my_definition
      my_definition = definitions.add "My Selection"
      #make my_instance out of group
      my_instance = my_group.to_component
      #add my_instance to my_definition
      my_definition.entities.add_instance(my_instance.definition, my_instance.transformation)
      

      Addenda: Where the previous is italicized, it reflects corrections by tt.

      1 Reply Last reply Reply Quote 0
      • K Offline
        kwistenbiebel
        last edited by

        Unfortunately you are facing a bug in Sketchup.

        1 Reply Last reply Reply Quote 0
        • tinanneT Offline
          tinanne
          last edited by

          I feel your pain. It seems that there is not much one can do about it. I'm hoping for that bug to be fixed, for sure!

          Executive Director : American Society of Architectural Illustrators
          AIP 30 Competition opens soon. ASAI.org

          Architectural Rendering

          1 Reply Last reply Reply Quote 0
          • honoluludesktopH Offline
            honoluludesktop
            last edited by

            As an ancient marina, the concepts of Ruby, and OPPS originally fail to easily register on my consciousness. The following is the degree to which I currently understand them as applied to SUs Ruby API.

            A class is the generic form of an object. Objects within a class share the same class characteristics, the differences between objects are found in their variable differences. A class "box", results in objects, that differ in height, width, or length.

            Methods nare procedures that dertermine a variable's value. For example, the boxes height = volume/(width*length).

            A SU Ruby plugin is a program that utilized the SU Ruby API to affect a SU model.

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

            Advertisement