Freedom Designator For Sketchup.docx

  • Uploaded by: pedrokalungsod
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Freedom Designator For Sketchup.docx as PDF for free.

More details

  • Words: 493
  • Pages: 10
STRUCTURAL ANALYSIS PLUGINS FOR SKETCHUP

THIS RUBY ALGORITHM IS THE ONE RESPONSIBLE FOR DECLARING THE DEGREES OF FREEDOM FOR EACH EDGE ENTITIES OF. class Node attr_accessor :vertex,:rotation,:constraints,:degreesOfFreedom

def initialize(vertex) self.constraints = [0,0,0] self.vertex = vertex self.degreesOfFreedom = [0,0,0] end

def setDegreesOfFreedomToEdges self.vertex.edges.each do |edge| nearFarStartEnd = setNearOrFar(edge,self.vertex.position) edge.set_attribute "Structural","#{nearFarStartEnd[0]}DegreesOfFreedom",degreesOfFreedom edge.set_attribute "Structural","#{nearFarStartEnd[0]}Index",nearFarStartEnd[1] end end

def getVertex() return self.vertex end

def getRotation return self.rotation end

def getConstraints return self.constraints end

def getDegreesOfFreedom return self.degreesOfFreedom end

def setNearOrFar(edge,node) point1 = edge.vertices[0].position point2 = edge.vertices[1].position origin = Geom::Point3d.new(0,0,0) distance1 = point1.distance(origin) distance2 = point2.distance(origin) nodeDesignation = [] if(distance1 >= distance2) if(point1 == node) nodeDesignation = ["far",1] else(point2 == node) nodeDesignation = ["near",0]

end else(distance1 < distance2) if(point1 == node) nodeDesignation = ["near",1] else(point2 == node) nodeDesignation = ["far",0] end end

return nodeDesignation

end

end

class FreedomDesignator attr_accessor :nodeArray,:indexOFConstraints,:degreesOfFreedom,:forceMatrix

def initialize self.nodeArray = [] self.indexOFConstraints = [] self.degreesOfFreedom = 1 end

# get methods

def getNodeArray() return self.nodeArray end

def getIndexOFConstraints() return self.indexOFConstraints end

def getDegreesOfFreedom() return self.degreesOfFreedom end

def getForceMatrix() return self.forceMatrix end

def mainProcess(entities)

supportEntities = entities.to_a.select{|se| (se.kind_of? Sketchup::Group) && ((se.get_attribute "Structural","type" ) == "support" )}

lineEntities = entities.to_a.select{ |le| le.kind_of? Sketchup::Edge} puts(lineEntities)

self.setNodeArray(lineEntities)

self.setRotationOfNodeArrayAndConstraints(supportEntities)

self.setDegOfFreedomToNodeArray()

self.setDegOfFreedomToConstraints()

"CHECKING : Final Output of Node Freedom" iterationForNodArray=0.0 nodeArray.each do |nA| puts "Node Array #{iterationForNodArray+1} degrees of freedom #{nA.degreesOfFreedom[0]},#{nA.degreesOfFreedom[1]},#{nA.degreesOfFreedom[2]}" iterationForNodArray+=1 end

self.setDegreesOfFreedomToMemberElements(lineEntities)

"CHECKING : Printing the degrees of freedom of the line entities" iterationForLineEntities = 1 lineEntities.each do |lE| nearDegreesOfFreedom = lE.get_attribute "Structural","nearDegreesOfFreedom"

farDegreesOfFreedom = lE.get_attribute "Structural","farDegreesOfFreedom"

puts "member #{iterationForLineEntities} #{nearDegreesOfFreedom} , #{farDegreesOfFreedom}" iterationForLineEntities+=1 end

end

def setDegreesOfFreedomToMemberElements(lineEntities) self.nodeArray.each do |nA| nA.setDegreesOfFreedomToEdges end end

def setNodeArray(lineEntities)

lineEntities.each do |le| vertex1 = le.vertices[0] vertex2 = le.vertices[1]

self.nodeArray << Node.new(vertex1) self.nodeArray << Node.new(vertex2)

end

self.nodeArray.uniq! { |nA| nA.vertex }

puts "CHECKING : Printing Node Array "

nodeArray.each do |nA| puts "#{nA.vertex.position}" end

end

def setRotationOfNodeArrayAndConstraints(supportEntities) puts "CHECKING : setRotationOfNodeArrayAndConstraints :: method start " puts "CHECKING : support entities #{supportEntities} " if(supportEntities) puts "CHECKING : Iterating through support entities" supportEntities.each do |sE| index = self.nodeArray.index{ |nA| nA.vertex.position == (sE.get_attribute "Properties","location") } self.nodeArray[index].rotation == self.getRotation(sE)

self.nodeArray[index].constraints = (sE.get_attribute "Structural","constraints") end end

puts "CHECKING : setRotationOfNodeArrayAndConstraints :: method end" end

def getRotation(supportEntities) return 0.0 end

def setDegOfFreedomToNodeArray() iterationForNodArray = 0 puts "CHECKING : setting the degrees of freedom to node array" self.nodeArray.each do |nA| iterationForConstraints = 0 nA.constraints.each do |const| if(const == 0) nA.degreesOfFreedom[iterationForConstraints] = self.degreesOfFreedom self.degreesOfFreedom += 1 elsif(const == 1) self.indexOFConstraints << [iterationForNodArray,iterationForConstraints] end iterationForConstraints +=1 end puts "Node Array #{iterationForNodArray+1} degrees of freedom #{nA.degreesOfFreedom[0]},#{nA.degreesOfFreedom[1]},#{nA.degreesOfFreedom[2]}" iterationForNodArray +=1

end puts "CHECKING : ending the degrees of freedom to node array" end

def setDegOfFreedomToConstraints()

puts "CHECKING : setting the degrees of freedom to constraints" puts "CHECKING : The number of constraints is #{self.indexOFConstraints.count}" self.indexOFConstraints.each do |inConst| nodeArray[inConst[0]].degreesOfFreedom[inConst[1]] = self.degreesOfFreedom self.degreesOfFreedom +=1 end

puts "CHECKING : ending the degrees of freedom to constraints"

end

end

# Default code, use or delete... mod = Sketchup.active_model # Open model

ent = mod.entities # All entities in model sel = mod.selection # Current selection

freedomDesignator = FreedomDesignator.new freedomDesignator.mainProcess(ent)

Related Documents


More Documents from "Emilia"