Is there maybe a way to divide an object into triangles?
because the add_face instruction can draw traingles..
is there a function for this?
thanks
Is there maybe a way to divide an object into triangles?
because the add_face instruction can draw traingles..
is there a function for this?
thanks
i left out the part of coloring the attributed items..
still only top of the walls don't get copied?
so why doesn't all the edges get copied into the group except te top of the walls?
because i use every point of all the edges?
doesnt face = gentities.add_face(edges2) work like it should?
or don't i use it correctley
edit::
i now changed something in my sketchupdesign..
i made the top of the wall smaller area's..
originaly the walls was one big area..
nog lets say every area has 4 different wall's..
and now it works like it should..
but it isnt very good for the usage in sketchup..
i think is must be possible to draw the whole big area..
but how?
@tig said:
First make an array of all active faces...
Then go through that and make a reduced array of faces+attributes...
Now process the list of found faces...
Perhaps, copy/move the faces' edges into the group and group.add_lines...edges.find_faces, for the set, as you go - no need to find all the vertices ?Seems your present code copies all faces ?
all the faces where there is an entity (attribute)
entities.each do |entity|
before i copied all the faces into a group, but for some reason sketchup forgot to copy all of the objects.. there where usualy 2 or 3 faces that didnt get copied into the group.. but they had attributes
hi
i'm working on a project where i have to copy some objects to another layer..
mostly it are rectangle objects..
with these objects there is no problem..
but i also need to copy walls.. but the walls aren't rectangle objects, because in my project they have 76 startpoints of the edges..
you can see in the code that only objects with attributes get a copy..
but in the picture i marked the part of the wall that has got an attribute, and the part that doesnt have an attribute.
i dont really understand why sketchup copy's the side of the wall instead of the top of the wall.. i think there most be something wrong with my methode of copying the edges..
maybe someone knows where there is an error in my code
model = Sketchup.active_model
entities = model.active_entities
layers = model.layers
new_layer = layers.add("Preview layer")
group = entities.add_group
group.layer = new_layer
gentities = group.entities
entities.each do |entity|
if (entity.typename == "Face")
edges = entity.edges
edges2 = Array.new
edges.each do |edge|
p1 = edge.start.position
p2 = edge.end.position
edges2.push(gentities.add_line(p1, p2))
end
face = gentities.add_face(edges2)
context = entity.get_attribute "locon", "context_info"
if(context != nil && face != nil)
face.material = $context_info_color[context]
face.back_material = $context_info_color[context]
end
end
end
pages = model.pages
page = pages.add "Preview"
activelayer = model.active_layer = layers[2]
layer = model.active_layer
layers.each do |layer|
if (layer.name == "Preview layer")
page.set_visibility layer, true
elsif
page.set_visibility layer, false
end
end
group.locked = true