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

Given a [x,y,z] delete a text note. Need help, Solved

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 3 Posters 348 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
    dukejazz
    last edited by dukejazz 1 Jun 2012, 13:28

    I have a update going and I have two problems to solve for
    scaleGroupFloat v1.2 bata
    WIP
    Is there a way in ruby code:
    1-given a xyz make a point +

    pic_0014.jpg

    2-given a xyz delete a text note
    pic_0015.jpg

    Need some help:
    1- best I can do is to draw a [x,y,z] center point vector line.
    2- I can make the note by [x,y,z] but, now I want to delete it by [x,y,z]

    ok
    Here my codes for 1 and 2 so far

    1)Sketchup.active_model.entities.add_line([0,0,0],[x,y,z])

    2)Sketchup.active_model.entities.add_text "a text note",(Geom::Point3d.new([x,y,z]))

    I need some helpful hints please.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 1 Jun 2012, 13:35

      You know the point
      pt=Geom::Point3d.new(x,y,z)
      You need to iterate the model's entities and find any text that is inserted at that very point and then erase it...
      model.active_entities.to_a.each{|e| e.erase! if e.is_a?(Sketchup::Text) and e.point==pt }
      🤓

      TIG

      1 Reply Last reply Reply Quote 0
      • D Offline
        dukejazz
        last edited by 1 Jun 2012, 14:34

        I was a early programmer in the 80's not bad at machine code,Assemble,fortran and basic. Then in Sept of this year I relize that ruby was easy to learn. I starting to pick at the API. I no expert I know about 10 to 15% at this point.

        I will work in API index areas with code you have given me thanks

        1 Reply Last reply Reply Quote 0
        • D Offline
          dukejazz
          last edited by 2 Jun 2012, 06:32

          My anser to question 1 is now solved: 😍
          Given a [x,y,z] make a point.
          API
          The position method is used to retrieve a Point3d used to create a construction point.

          
          Sketchup.active_model.active_entities.add_cpoint Geom;;Point3d.new (x,y,z)
          

          Thanks for the hint TIG

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 2 Jun 2012, 23:30

            .. but do not put spaces between the method name and the ( of the argument list.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              dukejazz
              last edited by 3 Jun 2012, 06:37

              I thank your right
              so I check my work
              API notes has this space too?

              Entities.add_cpointSketchUp 6.0+
              The add_cpoint method is used to create a construction point.

              model = Sketchup.active_model
              entities = model.active_entities
              point1 = Geom::Point3d.new (100,200,300)
              constpoint = entities.add_cpoint point1
              if (constpoint)
              UI.messagebox constpoint
              else
              UI.messagebox "Failure"
              end

              I used this in this form in my program

              Sketchup.active_model.active_entities.add_cpoint Geom::Point3d.new (dj_x1[9],dj_x1[10],dj_x1[11])

              edit for here

              Sketchup.active_model.active_entities.add_cpoint Geom::Point3d.new (x,y,z)

              you say

              Sketchup.active_model.active_entities.add_cpoint Geom::Point3d.new(x,y,z)

              both two form works.
              Thus I will concude
              Geom Classes allow a space
              wild other Classes don't allow

              Here the correction.

              Sketchup.active_model.active_entities.add_cpoint Geom::Point3d.new(x,y,z)

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

                pt = Geom::Point3d.new 100, 200, 300
                this currently works, and it is used in most of the API examples... BUT it might be deprecated in future versions of Ruby, so using '(' and ')' [parentheses] to enclose a methods argument[s] is always recommended, as shown below...
                pt = Geom::Point3d.new(100, 200, 300)

                • this is the preferred method - note how the opening '(' comes immediately after the method with NO space.
                  Using a space like this...
                  pt = Geom::Point3d.new (100, 200, 300)
                  can cause errors reports, although it might work some of the time... BUT it's always best to avoid a space before the opening '(' !

                TIG

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dukejazz
                  last edited by 3 Jun 2012, 23:42

                  Its a new day and I tried the code again.
                  the code works!
                  Thanks
                  TIG on Fri Jun 01, 2012 6:35 am

                  #first note written some min early.....
                  Sketchup.active_model.entities.add_text "Text note 1",(Geom::Point3d.new(x1,y1,z1))

                  #-Given a [x,y,z] delete a text note.
                  #erase note 1
                  Sketchup.active_model.active_entities.to_a.each{|e|
                  e.erase! if e.is_a?(Sketchup::Text) and e.point==Geom::Point3d.new(x1,y1,z1)
                  }
                  #-Thus Given a [x,y,z] delete a text note...Solved by TIG

                  #New note 2 written by it self
                  Sketchup.active_model.entities.add_text "Text note 2",(Geom::Point3d.new(x1,y1,z1))

                  Ya! Ho!

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

                  Advertisement