SAPAPI代码挡土墙.docx
《SAPAPI代码挡土墙.docx》由会员分享,可在线阅读,更多相关《SAPAPI代码挡土墙.docx(30页珍藏版)》请在冰豆网上搜索。
![SAPAPI代码挡土墙.docx](https://file1.bdocx.com/fileroot1/2023-2/21/17de67e8-7329-492a-8fb1-109aff36700a/17de67e8-7329-492a-8fb1-109aff36700a1.gif)
SAPAPI代码挡土墙
'FormWall1DCode
ImportsSystem.Math
PublicClassFromWall1D
DimTimeSumAsInteger=0
Dimi,j,kAsInteger
DimretAsLong
DimModelNameAsString
DimAboutBoxFlagAsBoolean=False
'点击一次即弹出ComboBox下拉菜单
PrivateSubDataGridView_CellEnter(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.DataGridViewCellEventArgs)HandlesDataGridView.CellEnter
DimdgvAsDataGridView=CType(sender,DataGridView)
Ifdgv.Columns(e.ColumnIndex).Name="DColumnConcreteGrade"Ordgv.Columns(e.ColumnIndex).Name="DColumnRebarClass"Then
SendKeys.Send("{F4}")
EndIf
EndSub
'初始化程序
PublicSubNew()
'此调用是Windows窗体设计器所必需的。
InitializeComponent()
'在InitializeComponent()调用之后添加任何初始化。
'初始化Datagridview
Me.DataGridView.AllowUserToAddRows=False
Me.DataGridView.AutoSizeColumnsMode=DataGridViewAutoSizeColumnsMode.Fill
Me.DataGridView.ColumnHeadersHeightSizeMode=DataGridViewColumnHeadersHeightSizeMode.DisableResizing
Me.DataGridView.ColumnHeadersHeight=20
'初始化地下室楼层总数为
Me.ComboBoxStoryNum.SelectedIndex=0
'初始化标准高度为
Me.ComboBoxStoryHeight.Text="3600"
'初始化标准墙厚为
Me.ComboBoxWallThickness.Text="300"
'初始化标准保护层厚度为
Me.ComboBoxConcreteCover.Text="30"
'初始化标准混凝土等级为C30
Me.ComboBoxConcreteGrade.SelectedIndex=1
'初始化标准钢筋等级为HRB400
Me.ComboBoxRebarClass.SelectedIndex=2
'初始化地下水距墙顶高差为
Me.ComboBoxWaterLevel.Text="4000"
'初始化场地距墙顶高差为
Me.ComboBoxSiteLevel.Text="300"
'初始化土容重为
Me.ComboBoxSoilUintWeight.Text="20"
'初始化土浮容重为
Me.ComboBoxSoilMergedUnitWeight.Text="11"
'初始化地面堆载为
Me.ComboBoxGroundLoad.Text="5"
'初始化土内摩擦角为
Me.ComboBoxInternalFrictionalAngle.Text="30"
'初始化土压力类型为静止土压力
Me.ComboBoxCalMethod.SelectedIndex=0
'初始化静止土压力折减系数为.0
Me.ComboBoxPressureReduce.Text="1.0"
'初始化墙顶约束为铰接
Me.ComboBoxRestraintTop.SelectedIndex=1
'初始化墙低约束为刚接
Me.ComboBoxRestraintBottom.SelectedIndex=1
'初始化标题列宽度不能改变
Me.DataGridView.RowHeadersWidthSizeMode=DataGridViewRowHeadersWidthSizeMode.DisableResizing
Me.DataGridView.RowHeadersWidth=25
'初始化标题行高度不能改变
Me.DataGridView.ColumnHeadersHeightSizeMode=DataGridViewColumnHeadersHeightSizeMode.DisableResizing
Me.DataGridView.ColumnHeadersHeight=25
EndSub
'楼层数赋值并调整DataGridView行数
PrivateSubComboBoxStoryNum_SelectedIndexChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxStoryNum.SelectedIndexChanged
Me.DataGridView.RowCount=ComboBoxStoryNum.Text
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(0,i).Value=-1*i-1&"F"
IfMe.DataGridView(1,i).Value=""Then
Me.DataGridView(1,i).Value=Me.ComboBoxStoryHeight.Text
EndIf
IfMe.DataGridView(2,i).Value=""Then
Me.DataGridView(2,i).Value=Me.ComboBoxWallThickness.Text
EndIf
IfMe.DataGridView(3,i).Value=""Then
Me.DataGridView(3,i).Value=Me.ComboBoxConcreteCover.Text
EndIf
IfMe.DataGridView(4,i).Value=""Then
Me.DataGridView(4,i).Value=Me.ComboBoxConcreteGrade.Text
EndIf
IfMe.DataGridView(5,i).Value=""Then
Me.DataGridView(5,i).Value=Me.ComboBoxRebarClass.Text
EndIf
Next
EndSub
'层高赋值
PrivateSubComboBoxStoryHeight_TextChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxStoryHeight.TextChanged
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(1,i).Value=Me.ComboBoxStoryHeight.Text
Next
EndSub
'墙厚赋值
PrivateSubComboBoxWallThickness_TextChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxWallThickness.TextChanged
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(2,i).Value=Me.ComboBoxWallThickness.Text
Next
EndSub
'保护层厚度赋值
PrivateSubComboBoxConcreteCover_TextChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxConcreteCover.TextChanged
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(3,i).Value=Me.ComboBoxConcreteCover.Text
Next
EndSub
'混凝土等级赋值
PrivateSubComboBoxConcreteGrade_SelectedIndexChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxConcreteGrade.SelectedIndexChanged
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(4,i).Value=Me.ComboBoxConcreteGrade.Text
Next
EndSub
'钢筋等级赋值
PrivateSubComboBoxRebarClass_SelectedIndexChanged(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesComboBoxRebarClass.SelectedIndexChanged
Fori=0ToMe.DataGridView.RowCount-1
Me.DataGridView(5,i).Value=Me.ComboBoxRebarClass.Text
Next
EndSub
'根据土压力计算类型不同调整土压力折减系数对话框有效性
PrivateSubComboBoxCalMethod_SelectedIndexChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesComboBoxCalMethod.SelectedIndexChanged
IfMe.ComboBoxCalMethod.SelectedIndex=0Then
Me.LabelPressureReduce.Enabled=True
Me.ComboBoxPressureReduce.Enabled=True
Else
Me.LabelPressureReduce.Enabled=False
Me.ComboBoxPressureReduce.SelectedIndex=1
Me.ComboBoxPressureReduce.Enabled=False
EndIf
EndSub
PrivateSubButtonOK_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButtonOK.Click
'当数据文件路径为空时
IfMe.TextBoxFilePath.Text=""Then
IfNotFileSave(Me)ThenExitSub
Else
IfGetFileString(Me)<>GetFileString(Me.TextBoxFilePath.Text)Then
DimMsgVal
MsgVal=MsgBox("当前数据与"&Me.TextBoxFilePath.Text&"数据不同,是否覆盖源文件?
",MsgBoxStyle.YesNoCancel,"提示")
SelectCaseMsgVal
Case6'选择Yes,覆盖源文件
IfNotFileSave(Me,Me.TextBoxFilePath.Text)ThenExitSub
Case7'选择No,另存新文件
IfNotFileSave(Me)ThenExitSub
Case2'选择Cancel,返回编辑
ExitSub
EndSelect
EndIf
EndIf
'当模型路径为空时
IfMe.TextBoxModelPath.Text=""Then
SaveFileDialog.Filter=("sdb(*.sdb)|*.sdb")
SaveFileDialog.Title="保存SAP2000模型文件(*.sdb)"
IfSaveFileDialog.ShowDialog=Windows.Forms.DialogResult.OKAndLen(SaveFileDialog.FileName)>0Then
ModelName=SaveFileDialog.FileName()
Me.TextBoxModelPath.Text=SaveFileDialog.FileName()
Else
ExitSub
EndIf
Else
ModelName=Me.TextBoxModelPath.Text
EndIf
'定义SAP2000变量
DimSAPObjectAsSAP2000v15.SapObject
DimSAPModelAsSAP2000v15.cSapModel
'定义层数并赋值
DimStoryNumAsInteger
StoryNum=Val(Me.ComboBoxStoryNum.Text)
'定义墙单元信息列表,包含-层号、-墙厚、-保护层厚、-混凝土等级、-钢筋等级、-Sap构件名称
DimWallElementsListAsArrayList=NewArrayList
Fori=0ToMe.DataGridView.RowCount-1
WallElementsList.Add(NewObject(){Me.DataGridView(0,i).Value,Me.DataGridView(1,i).Value,Me.DataGridView(2,i).Value,Me.DataGridView(3,i).Value,Me.DataGridView(4,i).Value,Me.DataGridView(5,i).Value,Me.DataGridView(0,i).Value+"-"+Me.DataGridView(2,i).Value+"-"+Me.DataGridView(3,i).Value+"-"+Me.DataGridView(4,i).Value+"-"+Me.DataGridView(5,i).Value})
Next
'定义层高列表并赋值
DimStoryHeightListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
StoryHeightList.Add(WallElementsList(i)
(1))
Next
'定义墙厚列表并赋值
DimWallThicknessListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
WallThicknessList.Add(WallElementsList(i)
(2))
Next
'定义混凝土保护层厚度列表并赋值
DimConcreteCoverListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
ConcreteCoverList.Add(WallElementsList(i)(3))
Next
'定义混凝土等级列表并赋值
DimConcreteGradeListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
ConcreteGradeList.Add(WallElementsList(i)(4))
Next
'定义钢筋等级列表并赋值
DimRebarClassListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
RebarClassList.Add(WallElementsList(i)(5))
Next
'定义Sap截面名称列表并赋值
DimSapMemberSectionListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
SapMemberSectionList.Add(WallElementsList(i)(6))
Next
'定义Sap构件名称列表并赋值
DimSapMemberNameListAsArrayList=NewArrayList
Fori=0ToStoryNum-1
SapMemberNameList.Add(WallElementsList(i)(0))
Next
'测试Sap构件名称列表是否正确
'Fori=0ToSapMemberNameList.Count-1
'MsgBox(SapMemberNameList(i))
'Next
'定义墙顶高出地下水距离
DimWaterLevelAsDouble
WaterLevel=Val(Me.ComboBoxWaterLevel.Text)
IfMe.ComboBoxWaterLevel.Text="不考虑水压"Then
Fori=0ToStoryHeightList.Count-1
WaterLevel=WaterLevel+Val(StoryHeightList(i).ToString)
Next
WaterLevel=WaterLevel+1000
EndIf
'定义墙顶高出场地距离
DimSiteLevelAsDouble
SiteLevel=Val(Me.ComboBoxSiteLevel.Text)
'定义土容重
DimSoilUnitWeightAsDouble
SoilUnitWeight=Val(Me.ComboBoxSoilUintWeight.Text)
'定义土浮容重
DimSoilMergedUnitWeightAsDouble
SoilMergedUnitWeight=Val(Me.ComboBoxSoilMergedUnitWeight.Text)
'定义地面堆载
DimGroundLoadAsDouble
GroundLoad=Val(Me.ComboBoxGroundLoad.Text)
'定义土内摩擦角
DimInternalFrictionalAngleAsDouble
InternalFrictionalAngle=Val(Me.ComboBoxInternalFrictionalAngle.Text)
'定义土侧压力计算类型
DimCalMethodAsString
CalMethod=Me.ComboBoxCalMethod.Text
'定义土压力折减系数
DimPressureReduceAsDouble
PressureReduce=Val(Me.ComboBoxPressureReduce.Text)
'定义墙顶约束
DimRestraintTopAsString
RestraintTop=Me.ComboBoxRestraintTop.Text
'定义墙底约束
DimRestraintBottomAsString
RestraintBottom=Me.ComboBoxRestraintBottom.Text
'实例化SAP2000对象
SAPObject=NewSAP2000v15.SapObject
'开启SAP2000并设置初始单位
SAPObject.ApplicationStart()
'实例化SAP2000模型对象()
SAPModel=SAPObject.SapModel
'创建初始化SAP2000模型()
SAPModel.InitializeNewModel()
'新建空白SAP2000模板
SAPObject.SapModel.File.NewBlank()
'设置模型单位为N_mm_C
SAPModel.SetPresentUnits(SAP2000v15.eUnits.N_mm_C)
'定义混凝土C25~C60的材质参数,依次为混凝土等级,弹性模量Ec,泊松比υc,线膨胀系数αc,标准抗压强度fc,压应力为fc时的应变ε,正截面极限压应变εcu
DimConcreteParameterAsArrayList=NewArrayList
ConcreteParameter.Add(NewObject(){"C25",2.8*10^4,0.2,0.00001,25,0.002,0.0033})
ConcreteParameter.Add(NewObject(){"C30",3.0*10^4,0.2,0.00001,30,0.002,0.0033})
ConcreteParameter.Add(NewObject(){"C35",3.15*10^4,0.2,0.00001,35,0.002,0.0033})
ConcreteParameter.Add(NewObject(){"C40",3.25*10^4,0.2,0.00001,40,0.002,0.0033})
ConcreteParameter.Add(NewObject(){"C45",3.35*10^4,0.2,