Given a [x,y,z] delete a text note. Need help, Solved
-
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 +2-given a xyz delete a text note
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 far1)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.
-
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 }
-
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
-
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
-
.. but do not put spaces between the method name and the ( of the argument list.
-
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"
endI 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 allowHere the correction.
Sketchup.active_model.active_entities.add_cpoint Geom::Point3d.new(x,y,z)
-
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 '(' !
- this is the preferred method - note how the opening '(' comes immediately after the method with NO space.
-
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!
Advertisement