Hola,
Estoy haciendo un programa, y quiero agregar mediante la API funciones, en particular del tipo Response Spectrum mediante el usuario o “User”. Sin embargo, sólo encuentro un método para este fin que es “SapModel.Func.FuncRS.SetNTC2008”, pero sólo ese, y no he encontrado la forma de agregar un espectro definido por el usuario, o de forma mas general definir una función.
Existe alguna forma de hacer lo que describo?, muchas gracias.
Elmer Cusipuma Pregunta respondida 22 abril 2022
1 Respuesta
Actualmente la función “User” solo está disponible en la API de Sap2000 v23
'add user RS function NumberItems = 6 ReDim Period(NumberItems - 1) ReDim Value(NumberItems - 1) Period(0) = 0.03: Value(0) = 0.4 Period(1) = 0.05: Value(1) = 2.2 Period(2) = 0.80: Value(2) = 2.2 Period(3) = 1.20: Value(3) = 1.0 Period(4) = 4.00: Value(4) = 0.2 Period(5) = 10.0: Value(5) = 0.05 ret = SapModel.Func.FuncRS.SetUser("RS-1", NumberItems, Period, Value, 0.04)
En ETABS v20 solo esta disponible la función
'add NTC2008 RS function ret = SapModel.Func.FuncRS.SetNTC2008("RS-1", 1, 45.9, 12.6, 1, 3, 2, 50, 0.2, 2.4, 0.3, 3, 2, 1, 1, 5, 1)
Para resolver el problema podrias utilizar las tablas interactivas de ETABS.
Aqui un ejemplo de como funciona las tablas mediante la API (Extraido de SAFE que también aplica a ETABS.)
Sub VerificationExample1001() Dim ret As Long 'set the following flag to True to attach to an existing instance of the program 'otherwise a new instance of the program will be started Dim AttachToInstance As Boolean AttachToInstance = False 'set the following flag to True to manually specify the path to SAFE.exe 'this allows for a connection to a version of SAFE other than the latest installation 'otherwise the latest installed version of SAFE will be launched Dim SpecifyPath As Boolean SpecifyPath = False 'if the above flag is set to True, specify the path to SAFE below Dim ProgramPath As String 'ProgramPath = "C:\Program Files\Computers and Structures\SAFE 20\SAFE.exe" 'full path to the model 'set it to the desired path of your model Dim ModelDirectory As String ModelDirectory = "C:\CSiAPIexample" If Len(Dir(ModelDirectory, vbDirectory)) = 0 Then MkDir ModelDirectory End If Dim ModelName As String ModelName = "API_1-001.fdb" Dim ModelPath As String ModelPath = ModelDirectory & Application.PathSeparator & ModelName 'create API helper object Dim myHelper As cHelper Set myHelper = New Helper 'dimension the program object as cOAPI type Dim mySAFEObject As cOAPI Set mySAFEObject = Nothing If AttachToInstance Then 'attach to a running instance of SAFE 'get the active object 'SAFE uses API infrastructure from ETABS; as a consequence, the main connection object is called the ETABSObject Set mySAFEObject = myHelper.GetObject("CSI.SAFE.API.ETABSObject") Else If SpecifyPath Then 'create an instance of the program object from the specified path Set mySAFEObject = myHelper.CreateObject(ProgramPath) Else 'create an instance of the program object from the latest installed SAFE 'SAFE uses API infrastructure from ETABS; as a consequence, the main connection object is called the ETABSObject Set mySAFEObject = myHelper.CreateObjectProgID("CSI.SAFE.API.ETABSObject") End If 'start SAFE application mySAFEObject.ApplicationStart End If 'Get a reference to cSapModel to access all OAPI classes and functions Dim mySapModel As cSapModel Set mySapModel = mySAFEObject.SapModel ''Initialize model ret = mySapModel.InitializeNewModel() ''Create steel deck template model ret = mySapModel.File.NewSteelDeck(2, 12, 12, 4, 4, 24, 24) 'Get available tables Dim NumberTables As Long Dim TableKey() As String Dim TableName() As String Dim ImportType() As Long Dim IsEmpty() As Boolean ret = mySapModel.DatabaseTables.GetAvailableTables(NumberTables, TableKey, TableName, ImportType) ret = mySapModel.DatabaseTables.GetAllTables(NumberTables, TableKey, TableName, ImportType, IsEmpty) Dim SelectedTable As String SelectedTable = TableKey(24) 'Get all fields Dim TableVersion As Long Dim NumberFields As Long Dim FieldKey() As String Dim FieldName() As String Dim Description() As String Dim UnitsString() As String Dim IsImportable() As Boolean ret = mySapModel.DatabaseTables.GetAllFieldsInTable(SelectedTable, TableVersion, NumberFields, FieldKey, FieldName, Description, UnitsString, IsImportable) 'Table data array Dim IsRowWise As Boolean IsRowWise = True Dim TableData() As String Dim DBforceUnits As eForce Dim DBlengthUnits As eLength Dim DBtemperatureUnits As eTemperature ret = mySapModel.GetDatabaseUnits_2(DBforceUnits, DBlengthUnits, DBtemperatureUnits) Dim forceUnits As eForce Dim lengthUnits As eLength Dim temperatureUnits As eTemperature ret = mySapModel.GetPresentUnits_2(forceUnits, lengthUnits, temperatureUnits) 'Table data array Dim GroupName As String Dim FieldKeyList() As String Dim FieldsKeysIncluded() As String Dim NumberRecords As Long Dim FillImportLog As Boolean FillImportLog = True Dim NumFatalErrors As Long Dim NumErrorsMsgs As Long Dim NumWarnMsgs As Long Dim NumInfoMsgs As Long Dim ImportLog As String Dim TableLength As Long ' Edit Area Uniform Load Assignment table SelectedTable = "Area Load Assignments - Uniform" ret = mySapModel.DatabaseTables.GetAllFieldsInTable(SelectedTable, TableVersion, NumberFields, FieldKey, FieldName, Description, UnitsString, IsImportable) ret = mySapModel.DatabaseTables.GetTableForEditingArray(SelectedTable, GroupName, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) TableData(3) = "0.0002" ' Dead load TableData(8) = "0.0008" ' Live load ret = mySapModel.DatabaseTables.SetTableForEditingArray(SelectedTable, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) ret = mySapModel.DatabaseTables.ApplyEditedTables(FillImportLog, NumFatalErrors, NumErrorsMsgs, NumWarnMsgs, NumInfoMsgs, ImportLog) ' Edit Load Combination Defintions table SelectedTable = "Load Combination Definitions" ret = mySapModel.DatabaseTables.GetAllFieldsInTable(SelectedTable, TableVersion, NumberFields, FieldKey, FieldName, Description, UnitsString, IsImportable) ret = mySapModel.DatabaseTables.GetTableForEditingArray(SelectedTable, GroupName, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) NumberRecords = 2 Dim FieldKeysIncludedLength As Long FieldKeysIncludedLength = UBound(FieldsKeysIncluded) - LBound(FieldsKeysIncluded) + 1 TableLength = FieldKeysIncludedLength * NumberRecords - 1 ReDim TableData(TableLength) TableData(0) = "Combination1" ' Name of combo TableData(1) = "Linear Add" ' Type of combo TableData(2) = "No" ' Is Auto TableData(3) = "Dead" ' Load Name TableData(5) = "1.2" ' SF of Dead Load TableData(8) = "Combination1" ' Name of combo TableData(11) = "Live" ' Load Name TableData(13) = "1.6" ' SF of Live Load ret = mySapModel.DatabaseTables.SetTableForEditingArray(SelectedTable, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) ret = mySapModel.DatabaseTables.ApplyEditedTables(FillImportLog, NumFatalErrors, NumErrorsMsgs, NumWarnMsgs, NumInfoMsgs, ImportLog) 'Run analysis ret = mySapModel.File.Save(ModelPath) ret = mySapModel.Analyze.RunAnalysis ' Retrieve joint displacements Dim NumberOfJoints As Long NumberOfJoints = 6 Dim SelectedJointLabel() As Long Dim JointLabel() As String Dim LoadCase() As String Dim JointUz() As Double ReDim SelectedJointLabel(NumberOfJoints) ReDim JointLabel(NumberOfJoints) ReDim LoadCase(NumberOfJoints) ReDim JointUz(NumberOfJoints) SelectedTable = "Joint Displacements" ret = mySapModel.DatabaseTables.GetTableForDisplayArray(SelectedTable, FieldKeyList, GroupName, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) SelectedJointLabel(1) = 17 SelectedJointLabel(2) = 19 SelectedJointLabel(3) = 21 SelectedJointLabel(4) = 23 SelectedJointLabel(5) = 25 SelectedJointLabel(6) = 27 Dim temp As Double For i = 1 To 6 temp = SelectedJointLabel(i) JointLabel(i) = TableData(temp * 11 * 3 - 10) LoadCase(i) = TableData(temp * 11 * 3 - 8) JointUz(i) = TableData(temp * 11 * 3 - 4) Next 'Start composite beam design ret = mySapModel.DesignCompositeBeam.StartDesign ' Retrieve composite beam design result Dim BeamName As String Dim BeamSection As String Dim StudLayout As Long Dim PMRatio As Double Dim ShearRatio As Double Dim CamberDeflection As Double ' Expected results for comparison (assumes US defaults) 'Dim ExpectedBeamName As String = "41" 'Dim ExpectedBeamSection As String = "W16x26" 'Dim ExpectedStudLayout As Long = 10 'Dim ExpectedPMRatio As Double = 0.666 'Dim ExpectedShearRatio As Double = 0.296 'Dim ExpectedCamberDeflection As Double = 0.957906 SelectedTable = "Composite Beam Design Envelope" ret = mySapModel.DatabaseTables.GetTableForDisplayArray(SelectedTable, FieldKeyList, GroupName, TableVersion, FieldsKeysIncluded, NumberRecords, TableData) BeamName = TableData(0) BeamSection = TableData(1) StudLayout = TableData(2) PMRatio = TableData(10) ShearRatio = TableData(11) CamberDeflection = TableData(14) 'Close SAFE mySAFEObject.ApplicationExit (False) 'Clean up variables mySapModel = Nothing mySAFEObject = Nothing 'Check ret value If ret = 0 Then MsgBox ("API script completed successfully.") Else MsgBox ("API script FAILED to complete.") End If End Sub
Elmer Cusipuma Pregunta respondida 22 abril 2022