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

Component definition script problem?

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 2 Posters 151 Views 2 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.
  • T Offline
    tomot
    last edited by 23 Jun 2012, 17:15

    The attached pictured code is a portion of a script. The script run without issue, until I remove or place elsewhere in the script the handrail code, rectangled in red. With the code rectangled in red removed, the script draws the "do intermediate landing" then crashes, the Ruby Console points to the line in yellow.

    any ideas what would cause this problem?


    code1.png

    [my plugins](http://thingsvirtual.blogspot.ca/)
    tomot

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 23 Jun 2012, 20:12

      Some line-numbers would help !
      Line #170 is where the error is.
      The '.entities' can't apply to 'def_stair' ?
      Is 'def_stair' a definition or an instance etc ??
      If you remove that red-block of code doesn't it fail at the next 'entities=...' for the intermediate landing ?

      As an aside... why are you applying materials to back faces ?
      Shouldn't you rails be made the right way round - not 'inside-out' ???

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomot
        last edited by 24 Jun 2012, 15:18

        1. I left the line numbers out, because they will change depending on the inclusion or exclusion of the red block of code.
        2. def_stair is a definition (attached pic) which is located right after the main dialog box and before any drawing routine.
        3. With the red block of code removed the code does not fail at the intermediate landing, it fails at the next routine which is the drawing of the lower stair drawing, as expressed in the Ruby Console pic.
        4. back faces: is my mistake, sloppy cutting and pasting of code from a glass material which requires materials expressed for both faces.
        5. Interestingly, as long as one or the other drawing routines in the red block of code. is in the script, at that place in the script, the script runs flawlessly. ...its very Frustrating 😢

        code3.png

        [my plugins](http://thingsvirtual.blogspot.ca/)
        tomot

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 24 Jun 2012, 18:27

          You still don't show what happens between creating an empty definition and then trying to add something to it...
          If you make a group OR a component-definition and you don't add something to its entities right away then you can find it will auto-erase - because empty definitions do not survive after some operations...
          Try making the definition and immediately adding something, e.g.
          @cpt=def_stair.entities.add_cpoint(ORIGIN)
          You can always use @cpt.erase! at the end ?????

          TIG

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomot
            last edited by 24 Jun 2012, 19:24

            If I understand you correctly, are you saying?

            1. leave one of the drawing routines in the (red block of code) in place.
            2. followed by an erase of this entity as per your reply.

            FYI: My goal ultimately is, to create an option menu where these 2 rail entities (red block of code) will either be all/ON, all/OFF, inside/only, outside/only, via user choice.

            I have no problem with an option menu it works! So I had to back track to find the source of the problem, which it turns out to be the railings. Strangely this error occurs only when I'm converting this script into a component definition. (where the user can place the component with the cursor). While the same script without component conversion works flawlessly (stair is placed at origin).

            [my plugins](http://thingsvirtual.blogspot.ca/)
            tomot

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 25 Jun 2012, 09:51

              You are only ever giving us half the story... 😕

              What I said before was:- if you make a new empty definition and then do other things then the system can auto-erase the empty object, so to ensure it's not empty either make it just before you want to add something to its entities, OR add a cpoint to its entities immediately after you make it at the start, that way it's not empty and no longer prone to disappear mysteriously - I think that is what's happening when you try to add something later and it says that '.entities' is not a method that can be used by 'Nil' - therefore the 'definition reference' is not valid or initially set properly [I haven't seen all of the code!]...

              Can you perhaps set out [in words] the structure of the 'parts' of your tool, so that we can see where you need to think about making the code 'robust'...

              TIG

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomot
                last edited by 25 Jun 2012, 17:15

                @tig said:

                You are only ever giving us half the story... 😕

                Sorry about that! I clearly had some difficulty thinking outside the box. The empty definition did not work in this case, so I added a dummy line definition entity and erased it.

                        #----Do dummy line
                        entities = def_stair.entities # def
                        line = entities.add_line (@p8, @p7)
                        entities.erase_entities line
                

                all is well now, thanks!


                stair1.png

                [my plugins](http://thingsvirtual.blogspot.ca/)
                tomot

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

                Advertisement