But it seems no way to calculate the area...
Latest posts made by CEIT81729
-
RE: How to see the results of this method?
-
How to see the results of this method?
def sum_area( material, entities, tr = Geom;;Transformation.new ) area = 0.0 for entity in entities if entity.is_a?( Sketchup;;Group ) area += sum_area( material, entity.entities, tr * entity.transformation ) elsif entity.is_a?( Sketchup;;ComponentInstance ) area += sum_area( material, entity.definition.entities, tr * entity.transformation ) elsif entity.is_a?( Sketchup;;Face ) && entity.material == material # (!) The area returned is the unscaled area of the definition. # Use the combined transformation to calculate the correct area. # (Sorry, I don't remember from the top of my head how one does that.) # # (!) Also not that this only takes into account materials on the front # of faces. You must decide if you want to take into account the back # size as well. area += entity.area end end area end
Thank you for your help!
-
How do I change this code?(deduct the overlapping area)
I want to deduct the overlapping area between componentinstance and componentinstance in model.
How do I change this code?
Thank you for your help!mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selectionas = mod.definitions["column"].instances
bs = mod.definitions["beam"].instanceshits = {} ### empty hash
as.each{|a|
es = a.parent.entities
hits[a]=[]
bs.each{|b|
next unless es = b.parent.entities ### same context
bb = a.bounds.intersect(b.bounds)
hits[a] << b if bb && bb.valid?
}
}
hits.each{|hit| puts "column #{hit[0]} intersects beam #{hit[1]}" }
-
RE: How do I change the code?
TO TIG:
Thank you for your reply!
If I want to get the component's dynamic attributes(lenx, leny...) by multiple components collision detection?
and I will deduction of the overlapping area(multiple components) after...
(1)multiple components collision detection
(2)get the component's dynamic attributes(lenx, leny...)Thank you for your help!
-
How do I change the code?
mod = Sketchup.active_model
ent = mod.entitiesq = Sketchup.active_model.selection.add(
Sketchup.active_model.definitions["aaa"].instances )a = Sketchup.active_model.selection.add(
Sketchup.active_model.definitions["bbb"].instances )bb = Geom::BoundingBox.new.add(q.bounds.intersect(a.bounds))
if bb.valid?
puts "a"
else
puts "b"
endIt can't run...
How do I change the code? -
Collision Detection
Hello everyone
The following figure...
a and b intersect
b and c intersect
a and c not intersectI get Leny, Lenz from dynamic attributes(inch)
How not to let the detected twice?(a&b and b&a)
Thank you for your help!
mod = Sketchup.active_model
ent = mod.entities
grp = ent.grep(Sketchup::ComponentInstance)
for i in 0...grp.length - 1
grp.each{ |g| next if g == grp[i] # skip comparing to self
bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds))
if bb.valid?#gg = g.get_attribute("dynamic_attributes","lenx","")
gg1 = g.get_attribute("dynamic_attributes","leny","")
gg2 = g.get_attribute("dynamic_attributes","lenz","")
#puts gg#.to_cm
puts gg1#.to_cm
puts gg2#.to_cm#gg3 = grp[i].get_attribute("dynamic_attributes","lenx","")
gg4 = grp[i].get_attribute("dynamic_attributes","leny","")
gg5 = grp[i].get_attribute("dynamic_attributes","lenz","")
#puts gg3#.to_cm
puts gg4#.to_cm
puts gg5#.to_cmq = gg1.to_i * gg2.to_i - gg4.to_i * gg5.to_i
puts q
#puts "#{g.name} and #{grp[i].name} intersect"
else
puts "#{g.name} and #{grp[i].name} do not intersect"
end
bb.clear
}
end
-
How to detect collisions between ComponentInstance?
Hello everyone
How to detect collisions between ComponentInstance?
e.g:
if name = "column" all component collision name = "beam" all component
do something...
else
do something...
endThank you for your answer!
-
How to detect collisions between ComponentInstance?
Hello everyone
How to detect collisions between ComponentInstance?
e.g:
if name = "column" all component collision name = "beam" all component
do something...
else
do something...
endThank you for your answer!
-
Automatically Calculate the Component's Area and Volume
Hello everyone:
I want to know how to automatically calculate the component's area and volume in the dynamic attributes.
p.s:Non-use formula input.
Such as following example.
Thank you for your answer.
-
Detect object intersect
Hello everyone
mod = Sketchup.active_model
ent = mod.entities
grp = ent.grep(Sketchup::ComponentInstance)
for i in 0...grp.length - 1
grp.each{ |g| next if g == grp[i]
bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds))
if bb.valid?
puts "#{g.name.to_s} and #{grp[i].name.to_s} intersect"
else
puts "#{g.name.to_s} and #{grp[i].name.to_s} do not intersect"
end
bb.clear
}
endI want to know how to calculate the model of dynamic properties of all objects (such as "Lenx", "Leny" ,"Lenz"...etc) after the object intersected the other object.
The case description like this:
First, detect all objects intersect situations like the above code
Second, if name = "column" objects intersect name = "beam" objects(just a simple example)
then, "column" objects dynamic properties("Lenx") deduction "beam" objects dynamic properties("Leny")Thank you for your advice and help