Add attributes to a face???
-
You can add attributes to any Entity. The attributes are stored with the face, so if you delete the face it disappears. To retrieve the attribute again you use
get_attribute
on that face. -
@thomthom said:
You can add attributes to any Entity. The attributes are stored with the face, so if you delete the face it disappears. To retrieve the attribute again you use
get_attribute
on that face.how to realize this?
if i select a face and i want to set an attribute "wall" to the face.
thank u~ -
To set it
face=model.selection[0] face.set_attibute("McDullAttribute","Wall",true) ### this gives the face your-attribute called Wall that is true
To get it
face=model.selection[0] is_wall=face.get_attibute("McDullAttribute","Wall") if is_wall puts "This face is a Wall" else puts "This face is NOT a Wall" end#if
You can work out how to set/get the attributes of any entity like this...
-
thank u very much.as i use this method,it appears a error message:
Error; #<NoMethodError; d;\test.rb;3; undefined method `set_attibute' for #<Sketchup;;Face;0x5fa96a8>>
i check the sketchup ruby api document.face has not the set_attibute, just the entity has it.
so do i need to do it like this:face = entities.add_face pts entity1 = entities[1] status = entity1.set_attribute("McDullAttribute","Wall",true)
but the face has been exist before, i should not use
face = entities.add_face pts
,but use select method
-
Sorry about the typo for attibute read
attribute
-
@mcdull said:
i check the sketchup ruby api document.face has not the set_attibute, just the entity has it.
so do i need to do it like this:Code; Select all > face = entities.add_face pts > entity1 = entities[1] > status = entity1.set_attribute("McDullAttribute","Wall",true)
The
Face
class extends theEntity
class. So aFace
class has all the methods of theEntity
class.face = entities.add_face(pts) status = face.set_attribute("McDullAttribute","Wall",true)
In the API, for each class you see which class it extends (if any)
Example: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/face.html
Notice that right before the list of methods it says "Parent: Drawingelement".And you also got this diagram you can use as a reference to see how the classes are related: http://code.google.com/intl/nb/apis/sketchup/docs/diagram.html
Doing this:
face = entities.add_face pts entity1 = entities[1]
Gives you no guaranty that you get the face. You could be getting any random entity that way.
-
@tig said:
Sorry about the typo for attibute read
attribute
I'm a newer to use sketchup ruby api and i am so careless to find the little mistake.
thank u very much.u are so kind ~ -
i got it,i know that Entity is the parent class,but there is a spelling mistake and i am too careless to find it. thank u very much~
-
Dear jewellers,
your discussion give me an idea...
If it is possible to define attributes for entities like faces, what about using this method to create an area reporter with the area of each face embeded in an attribute?
It would be wonderfull if the area of the face (or collection of faces) could be updated if the geometry is changed... -
@baldaman said:
Dear jewellers,
your discussion give me an idea...
If it is possible to define attributes for entities like faces, what about using this method to create an area reporter with the area of each face embeded in an attribute?
It would be wonderfull if the area of the face (or collection of faces) could be updated if the geometry is changed...I have something like that in the workings already.
-
I'm amazed that you keep coming back to the observer's Thom They have caused you so much pain already.
-
@chris fullmer said:
I'm amazed that you keep coming back to the observer's Thom They have caused you so much pain already.
well... that's the part I haven't done yet. there is an issue with the area calculation SU does when you have skewed groups/components. haven't gotten to the part of adding the observers yet. But I dread it. I've yet not dared to go back to DoubleCut.
Advertisement