I’m trying to make it to where after I add the edges the faces will form automatically. I’m not really sure if I am doing that right though. Also after forming the faces I intend to bring the insulator layer up 10 mm and subtract the via from it.
Thanks!
module Practice
model = Sketchup.active_model # Open model
ents = model.active_entities
layers_array = model.layers
# add layers to the array.
substrate_tag = layers_array.add "substrate"
insulator_tag = layers_array.add "insulator"
via_tag = layers_array.add "via"
# create substrate
substrate = ents.add_group # add substrate group
substrate.name = "substrate" # name substrate group
sub_face = substrate.entities.add_face [0,0,0], [5,0,0], [5,8,0], [0,8,0] # add face
if sub_face.normal.z == 1 # want to extrude in negative direction
sub_face.reverse!
end
sub_face.pushpull 10.mm # extrude 10mm below
substrate.layer=substrate_tag # add layer tag.
# now do via and insulator layer
via = ents.add_group
via.name = "via"
via_faces=[]
via_faces.push(via.entities.add_face [1,1,0], [4,1,0],[4,3,0],[1,3,0])
via_faces.push(via.entities.add_face [1,5,0], [4,5,0],[4,7,0],[1,7,0])
# get the positions for each vertex [DOESN'T WORK]
#via_faces.each{|face| face.vertices.each{|vertex| vertex.position}}
# go up by 25 mm
vector = Geom::Vector3d.new(0, 0, 25.mm)
# create a new edge for each point
for face in via_faces do
for vertex in face.vertices
via.entities.add_edges(vertex.position,vertex.position+vector)
end
end
via.layer = via_tag
#via_faces.each{|face| face.reverse! if face.normal.z == -1}
#via_faces.each{|face| face.pushpull(thickness.mm)}
#top_via_faces=via.entities.find_all{|ent| ent.typename == "Face" && ent.normal == [0, 0, 1]}
# access vertices
#top_via_faces.each{|face| p face.vertices.position}
#verts = top_via_faces.each{|face| p face.vertices.each{|vertex| p vertex.position}}
#via_copy = via.parent.entities.add_instance(via.definition, via.transformation)
# now do insulator
insulator = ents.add_group
insulator.name = "insulator"
ins_face = insulator.entities.add_face [0,0,0], [5,0,0], [5,8,0], [0,8,0]
if ins_face.normal.z == -1 # want to extrude in negative direction
ins_face.reverse!
end
ins_face.pushpull 10.mm
#insulator = via.subtract(insulator)
insulator.layer = insulator_tag
model.rendering_options['DisplayColorByLayer']= true # colors each layer
end