def getBeamShapeBlocks(self, factor, blockProperties=None): ''' Return the faces of the beams. :param factor: factor multiplies the unary direction vector of the member to define its extrusion direction and lenght. :param blockProperties: labels and attributes to assign to the newly created blocks. ''' retval = bte.BlockData() beamBlocks = super(Connection, self).getBeamShapeBlocks(factor) retval.extend(beamBlocks) plateProperties = bte.BlockProperties.copyFrom(blockProperties) plateProperties.appendAttribute('objType', 'flange_plate') # Flange plates. for b in self.beams: flangePlate = b.getFlangeBoltedPlate(self.boltSteel) origin = self.getOrigin() print('origin: ', origin, ' beam origin: ', b.memberOrigin) baseVectors = b.getDirection(origin) halfH = (b.shape.h() + b.shape.getFlangeThickness() + flangePlate.thickness) / 2.0 halfD = flangePlate.length / 2.0 print('half H:', halfH * 1e3, 'mm') print('half D:', halfD * 1e3, 'mm') # Top plate topPlateCenter = b.memberOrigin + halfH * baseVectors[ 1] + halfD * baseVectors[0] topPlateRefSys = geom.Ref3d3d(topPlateCenter, baseVectors[0], baseVectors[2]) topPlateBlocks = flangePlate.getBlocks( refSys=topPlateRefSys, blockProperties=plateProperties) retval.extend(topPlateBlocks) # Holes in top flange print('has holes: ', topPlateBlocks.hasHoles()) holesList = topPlateBlocks.getHoles() for holes in holesList: for key in holes.points: p = holes.points[key] objType = p.getAttribute('objType') if (objType == 'hole_center'): pos = geom.Pos3d(p.getX(), p.getY(), p.getZ()) diameter = p.getAttribute('diameter') nearestFace = beamBlocks.getNearest(pos) posInFlange = nearestFace.getGeomObject( beamBlocks.points).getPlane().getPos3dProjection( pos) dist = posInFlange.dist(pos) print(pos, objType, diameter, nearestFace.id, dist) XXX quit() # Bottom plate bottomPlateCenter = b.memberOrigin - halfH * baseVectors[ 1] + halfD * baseVectors[0] bottomPlateRefSys = geom.Ref3d3d(bottomPlateCenter, baseVectors[0], baseVectors[2]) bottomPlateBlocks = flangePlate.getBlocks( refSys=bottomPlateRefSys, blockProperties=plateProperties) retval.extend(bottomPlateBlocks) return retval
def getHoleAsPolygon(self, refSys= geom.Ref3d3d(), nSides= 8): ''' Return a polygon inscribed in the hole. :param refSys: coordinate reference system. :param blockProperties: number of sides for the polygon representing the hole contour. ''' hole= self.getHole(refSys) retval= hole.getInscribedPolygon(8,0.0) return retval
def getHole(self, refSys= geom.Ref3d3d()): ''' Return a circle in the hole position. :param refSys: coordinate reference system. ''' pLocal= geom.Pos2d(self.pos3d.x, self.pos3d.y) holeDiameter= self.getNominalHoleDiameter() circle2d= geom.Circle2d(pLocal,holeDiameter/2.0) return geom.Circle3d(refSys, circle2d)
def getPositions(self, refSys=geom.Ref3d3d()): ''' Return the global coordinates of the bolts. :param refSys: reference system. ''' localPos = self.getLocalPositions() retval = list() for pLocal in localPos: p3d = geom.Pos3d(pLocal.x, pLocal.y, 0.0) retval.append(refSys.getPosGlobal(p3d)) return retval
def get_polygon_axis(points, tol): '''Compute the polygon axis on the assumption that they all the sides are orthogonal.''' pline= geom.Polyline3d() for p in points: pline.appendVertex(geom.Pos3d(p[0],p[1],p[2])) pline.simplify(tol) pt0= pline[1] pt1= pline[2] pt2= pline[3] v1= pt0-pt1 v2= pt2-pt1 return geom.Ref3d3d(pt1,v1,v2)
def get_polyface_points_axis(polyface_points): ''' Return the axis for the polyface.''' p= geom.Plane3d() p.linearLeastSquaresFitting(polyface_points) global_z= geom.Vector3d(0.0,0.0,1.0) local_z= p.getNormal() angle= local_z.getAngle(global_z) local_y= global_z global_y= geom.Vector3d(0.0,1.0,0.0) if(abs(angle)<1e-3 or abs(angle-math.pi)<1e-3): local_y= global_y local_x= local_y.cross(local_z) local_y= local_z.cross(local_x) org= polyface_points[0] return geom.Ref3d3d(org,local_x,local_y)
def get_principal_axis_3D(points): ''' Compute principal axes :param points: 3D point cloud. ''' #create coordinates array coord = numpy.array(points, float) # compute geometric center center = numpy.mean(coord, 0) # center with geometric center coord = coord - center # compute principal axis matrix inertia = numpy.dot(coord.transpose(), coord) e_values, e_vectors = numpy.linalg.eig(inertia) # warning eigen values are not necessary ordered! # http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.eig.html #-------------------------------------------------------------------------- # order eigen values (and eigen vectors) # # axis1 is the principal axis with the biggest eigen value (eval1) # axis2 is the principal axis with the second biggest eigen value (eval2) # axis3 is the principal axis with the smallest eigen value (eval3) #-------------------------------------------------------------------------- order = numpy.argsort(e_values) eval3, eval2, eval1 = e_values[order] axis3, axis2, axis1 = e_vectors[:, order].transpose() # scale factor to enhance the length of axis in Pymol scale_factor = 20 #-------------------------------------------------------------------------- # center axes to the geometric center of the molecule # and rescale them by order of eigen values #-------------------------------------------------------------------------- # the large vector is the first principal axis v1 = 3 * scale_factor * axis1 # the medium vector is the second principal axis v2 = 2 * scale_factor * axis2 # the small vector is the third principal axis v3 = 1 * scale_factor * axis3 return geom.Ref3d3d(geom.Pos3d(center[0], center[1], center[2]), geom.Vector3d(v1[0], v1[1], v1[2]), geom.Vector3d(v2[0], v2[1], v2[2]), geom.Vector3d(v3[0], v3[1], v3[2]))
def getAnchorBlock(self, refSys= geom.Ref3d3d(), blockProperties= None): ''' Return the hole contour and hole center as block topology entities. :param refSys: coordinate reference system. :param blockProperties: labels and attributes to assign to the newly created blocks. ''' retval= bte.BlockData() blk= super(AnchorBase, self).getBoltBlock(refSys, blockProperties) retval.extend(blk) # Anchor point. anchorPointProperties= self.getAnchorPointBlockProperties(blockProperties) pA= blk.topPoint center3d= geom.Pos3d(pA.coords[0], pA.coords[1], pA.coords[2]) pB= retval.appendPoint(-1, center3d.x, center3d.y, center3d.z-1*self.diameter, pointProperties= anchorPointProperties) boltBlk= bte.BlockRecord(id= -1, typ= 'line', kPoints= [pA.id, pB]) id= retval.appendBlock(boltBlk) return retval
def getBoltBlock(self, refSys= geom.Ref3d3d(), blockProperties= None): ''' Return the hole contour and hole center as block topology entities. :param refSys: coordinate reference system. :param blockProperties: labels and attributes to assign to the newly created blocks. ''' retval= bte.BlockData() # Hole vertices. holeProperties= bte.BlockProperties.copyFrom(blockProperties) holeProperties.appendAttribute('objType', 'hole') octagon= self.getHoleAsPolygon(refSys, nSides= 8).getVertexList() blk= retval.blockFromPoints(octagon, holeProperties) # Hole center. centerProperties= self.getHoleCenterBlockProperties(blockProperties, blk.id) center3d= refSys.getPosGlobal(self.pos3d) pA= retval.appendPoint(-1, center3d.x, center3d.y, center3d.z, pointProperties= centerProperties) retval.topPoint= retval.points[pA] return retval
def createHolesOnMemberBlocks(templateHoles, memberBlocks, boltProperties, materialsModuleName): ''' Projects the holes in the argument onto the surfaces of the member blocks to create the holes in those surfaces. :param templateHoles: holes that will be projected on the member surfaces, typically from a bolted plate that will be attached to the member. :param memberBlocks: surfaces corresponding to the member plates: flanges, web, etc. Those surfaces will receive the new holes into them. :param blockProperties: labels and attributes to assign to the newly created blocks. :param materialsModuleName: name of the module that contains the material for the new bolts. ''' retval = bte.BlockData() # Import the materials module matModule = importlib.import_module(materialsModuleName) for holes in templateHoles: for key in holes.points: p = holes.points[key] objType = p.getAttribute('objType') if (objType == 'hole_center'): pos = geom.Pos3d(p.getX(), p.getY(), p.getZ()) boltDiameter = p.getAttribute('diameter') boltMaterialId = p.getAttribute('boltMaterial') boltMaterial = getattr(matModule, boltMaterialId) nearestFace = memberBlocks.getNearest(pos) boltProperties.appendAttribute( 'ownerId', 'f' + str(nearestFace.id)) # Hole owner nearestFacePlane = nearestFace.getGeomObject( memberBlocks.points).getPlane() posInFlange = nearestFacePlane.getPos3dProjection(pos) refSys = geom.Ref3d3d(posInFlange, nearestFacePlane.getBase1(), nearestFacePlane.getBase2()) bolt = matModule.BoltFastener(diameter=boltDiameter, steelType=boltMaterial, pos3d=geom.Pos3d(0, 0, 0)) boltBlk = bolt.getBoltBlock(refSys, boltProperties) retval.extend(boltBlk) return retval
def getBlocks(self, refSys=geom.Ref3d3d(), blockProperties=None, loadTag=None, loadDirI=None, loadDirJ=None, loadDirK=None): ''' Return the blocks that define the plate for the diagonal argument. :param blockProperties: labels and attributes to assign to the newly created blocks. :param loadTag: tag of the applied loads in the internal forces file. :param loadDirI: I vector of the original element. Vector that points to the loaded side of the plate. :param loadDirJ: J vector of the of the original element. :param loadDirK: K vector of the of the original element. ''' retval = bte.BlockData() plateProperties = bte.BlockProperties.copyFrom(blockProperties) plateProperties.appendAttribute('objType', 'bolted_plate') if (loadTag): plateProperties.appendAttribute('loadTag', loadTag) plateProperties.appendAttribute( 'loadDirI', [loadDirI.x, loadDirI.y, loadDirI.z]) plateProperties.appendAttribute( 'loadDirJ', [loadDirJ.x, loadDirJ.y, loadDirJ.z]) plateProperties.appendAttribute( 'loadDirK', [loadDirK.x, loadDirK.y, loadDirK.z]) # Get the plate contour contourVertices = self.getContour(refSys) blk = retval.blockFromPoints(contourVertices, plateProperties, thickness=self.thickness, matId=self.steelType.name) # Get the hole blocks for the new plate holeProperties = bte.BlockProperties.copyFrom(blockProperties) holeProperties.appendAttribute('objType', 'hole') holeProperties.appendAttribute('ownerId', 'f' + str(blk.id)) blk.holes = self.boltArray.getHoleBlocks(refSys, holeProperties) retval.extend(blk.holes) return retval
def getHoleBlocks(self, refSys=geom.Ref3d3d(), blockProperties=None): ''' Return octagons inscribed in the holes. :param refSys: coordinate reference system used to compute the geometry of the holes. :param blockProperties: labels and attributes of the holes. ''' localPos = self.getLocalPositions() holes = list() for pLocal in localPos: circle = geom.Circle2d(pLocal, self.bolt.getNominalHoleDiameter() / 2.0) octagon = circle.getInscribedPolygon(8, 0.0).getVertexList() holes.append((pLocal, octagon)) retval = bte.BlockData() # Base points (A) for h in holes: # Hole vertices. holeVertices = list() for v in h[1]: p3d = geom.Pos3d(v.x, v.y, 0.0) holeVertices.append(refSys.getPosGlobal(p3d)) blk = retval.blockFromPoints(holeVertices, blockProperties) # Hole center. centerProperties = bte.BlockProperties.copyFrom(blockProperties) centerProperties.appendAttribute('objType', 'hole_center') centerProperties.appendAttribute('ownerId', 'f' + str(blk.id)) # Hole center owner. centerProperties.appendAttribute('diameter', self.bolt.diameter) centerProperties.appendAttribute('boltMaterial', self.bolt.steelType.name) center = h[0] center3d = refSys.getPosGlobal(geom.Pos3d(center.x, center.y, 0.0)) retval.appendPoint(-1, center3d.x, center3d.y, center3d.z, pointProperties=centerProperties) return retval
def getReferenceSystem(self): ''' Return the connection reference system.''' origin = self.getOrigin() #plane= geom.Plane3d(origin, self.column.getDirection(origin)) return geom.Ref3d3d(origin, self.column.jVector, self.column.kVector)
def getLocalRefSys(self): ''' Return the local reference system.''' return geom.Ref3d3d(self.origin)
# -*- coding: utf-8 -*- import math import xc_base import geom p1=geom.Pos3d(1,1,1) p2=geom.Pos3d(2,2,2) ref= geom.Ref3d3d(p1,p2) v= geom.Vector3d(1,1,1) vTrf= ref.getCooLocales(v) vTrfTeor= geom.Vector3d(math.sqrt(3.0),0,0) ratio= (vTrf-vTrfTeor).getModulo() p0= ref.getPosGlobal(geom.Pos3d(0.0,0.0,0.0)) ratio2= (p1-p0).getModulo() p0= geom.Pos3d(0,0,0) pA= geom.Pos3d(1,0,0) pB= geom.Pos3d(0,1,0) ref= geom.Ref3d3d(p0,pA,pB) ref.Org+=geom.Vector3d(1,1,1) ratio3= p1.distPos3d(ref.Org) # print "vTrf= ", vTrf # print "ratio= ", ratio # print "p0= ", p0 # print "ratio2= ", ratio2 # print ref.Org # print "ratio3= ", ratio3
__author__= "Luis C. Pérez Tato (LCPT)" __copyright__= "Copyright 2014, LCPT" __license__= "GPL" __version__= "3.0" __email__= "*****@*****.**" feProblem= xc.FEProblem() feProblem.logFileName= "/tmp/borrar.log" # Ignore warning messages preprocessor= feProblem.getPreprocessor points= preprocessor.getCad.getPoints pt1= points.newPntIDPos3d(1,geom.Pos3d(1.0,1.0,0.0)) pt2= points.newPntIDPos3d(2,geom.Pos3d(2,2,0)) pt3= points.newPntIDPos3d(3,geom.Pos3d(0,1,0)) rs= geom.Ref3d3d(pt1.getPos,pt2.getPos,pt3.getPos) p= rs.getPosGlobal(geom.Pos3d(7, 0, 0)) nodes= preprocessor.getNodeLoader nodes.defaultTag= 1 #First node number. nod1= nodes.newNodeXYZ(p.x,p.y,p.z) coord= nod1.getCoo ratio1= (coord[0]-5.9497475) ratio2= coord[1]-5.9497475 ratio3= coord[2] ''' print "ratio1= ",(ratio1)
def getBoltRefSys(self): ''' Return the reference system for the bolt array.''' boltCenter = self.gussetTip - self.iVector * ( self.boltedPlateTemplate.length / 2.0) halfChamferVector = self.halfChamfer.normalized() return geom.Ref3d3d(boltCenter, self.iVector, halfChamferVector)