sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    HELP WITH THIS CODE, please?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 269 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.
    • D Offline
      DIEGO-RODRIGUEZ
      last edited by DIEGO-RODRIGUEZ

      can someone tell me how to correct this code?
      Gracias.
      elcorto Argentina

      model = Sketchup.active_model
      entities = model.active_entities

      pz=[]

      pz[0]=[0,-100.mm,0]
      pz[1]=[100.mm,-100.mm,0]
      pz[2]=[100.mm,-81.mm,0]
      pz[3]=[0,-81.mm,0]

      edges = entities.add_edges([0, 560.mm, 0],[600.mm,560.mm,0],[600.mm,560.mm,720.mm],[0, 560.mm, 720.mm],[0, 560.mm, 0])

      facez = entities.add_face pz
      facez.followme(edges)

      http://img5.imageshack.us/img5/1426/82709271.jpg

      By elcorto at 2009-04-21



      entities = model.active_entities
      
      ancho = 600.mm 
      alto = 720.mm 
      n = 24
      r = 100.mm  
      
      
      edges = entities.add_edges([0, 0, 0],[ancho/2,0, 0],[ancho,0,0],[ancho, 0, alto],[0, 0, alto],[0, 0, 0],[ancho/2, 0, 0])
      circle = entities.add_circle([0,ancho/2,0], X_AXIS, r, n)
      base = entities.add_face(circle)
      base.followme(edges)  
      

      end

      http://img220.imageshack.us/img220/8352/72683910.jpg

      By elcorto at 2009-04-21

      1 Reply Last reply Reply Quote 0
      • M Offline
        mattscar
        last edited by

        In the first case, you should should create a curve instead of an array of Edges. Replace

        edges = entities.add_edges([0, 560.mm, 0],[600.mm,560.mm,0],[600.mm,560.mm,720.mm],[0, 560.mm, 720.mm],[0, 560.mm, 0])
        

        with

        edges = entities.add_curve([0, 560.mm, 0],[600.mm,560.mm,0],[600.mm,560.mm,720.mm],[0, 560.mm, 720.mm],[0, 560.mm, 0])
        

        In the second case, it looks like you want the base to be a semi-circle instead of a circle. You should replace

        circle = entities.add_circle([0,ancho/2,0], X_AXIS, r, n)
        base = entities.add_face(circle)
        

        with

        
        arc = entities.add_arc([0,ancho/2,0], [0, 0, 1], X_AXIS, r, 0.degrees, 180.degrees, n)
        arc << entities.add_line(arc[arc.length-1].end, arc[0].start)
        base = entities.add_face(arc)
        

        Hope this at least gets you closer to solving your problems.

        Matt

        1 Reply Last reply Reply Quote 0
        • D Offline
          DIEGO-RODRIGUEZ
          last edited by

          muchisimas gracias por tu ayuda.

          1 Reply Last reply Reply Quote 0
          • D Offline
            DIEGO-RODRIGUEZ
            last edited by

            How can I put the two codes in a single dialog box?
            And HOW DO PARAMETER?


            choose=[ "Frente 1", "Frente 2" ]
            enums=[choose.join("|")]
            prompts=[ "TIPO", "Ancho", "Alto", "Espesor"]
            values=[@choose, 600.mm, 709.mm, 19.mm]
            results=inputbox prompts, values, enums, "Parametros del frente"
            return if not results
            @choose, $a, $b, $c=results

            ###########Frente 1
            pz=[]
            pz[0]=[0,0,0]
            pz[1]=[100.mm,0,0]
            pz[2]=[100.mm,-c,0]
            pz[3]=[0,-c,0]
            edges = entities.add_curve([0, 560.mm, 0],[a,560.mm,0],[a,560.mm,b],[0, 560.mm, b],[0, 560.mm, 0])
            facez = entities.add_face pz
            facez.followme(edges)

            ###########Frente 2
            ancho = 600.mm
            alto = 709.mm
            n = 24
            r = 19.mm

            edges = entities.add_edges([0, 0, 0],[ancho/2,0, 0],[ancho,0,0],[ancho, 0, alto],[0, 0, alto],[0, 0, 0],[ancho/2, 0, 0])

            arc = entities.add_arc([0,ancho/2,0], [0, 0, 1], X_AXIS, r, 0.degrees, 180.degrees, n)
            arc << entities.add_line(arc[arc.length-1].end, arc[0].start)
            base = entities.add_face(arc)
            base.followme(edges)


            Muchas gracias.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              If you don't use @xxx in front of the variable name it will work - xxx. If you use @xxx the last values you entered are remembered. Don't mix @xxx and $xxx like this - I recommend you stay with @xxx. However, you must assign the @xxx values before the dialog first runs - like this [###=changes]

              
              choose=[ "Frente 1", "Frente 2" ]
              @choose="Frente 1" ### set initial [default] @choose
              enums=[choose.join("|")] ### you just could use emuns=["Frente 1|Frente 2"]
              prompts=["TIPO","Ancho","Alto","Espesor"]
              @a=600.mm if not @a ### set defaults for @a - any changes to @a will be remembered for that session of SUp...
              @b=709.mm if not @b ###
              @c=19.mm if not @c  ###
              values=[@choose, @a, @b, @c]###
              results=inputbox(prompts,values,enums,"Parametros del frente")
              return nil if not results ### 'nil'
              @choose,@a,@b,@c=results ### $a >>> @a etc
              ########### Frente 1
              pz=[]
              pz[0]=[0,0,0]
              pz[1]=[100.mm,0,0]
              pz[2]=[100.mm,-@c,0]###
              pz[3]=[0,-@c,0]###
              edges=entities.add_curve([0,560.mm,0],[@a,560.mm,0],[@a,560.mm,@b],[0,560.mm,@b],[0,560.mm,0])### a >>> @a etc
              facez=entities.add_face(pz)
              facez.followme(edges)
              ### etc etc
              
              

              TIG

              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