Hi all,
I need to understand some concept regarding the creation of section database users and how they work. I have a problem and it is possibly due to lack of knowledge of how it works:
But then, when I create a new element in the user db, and later I try to generate the section to asign it for a member by API code by following code (or trying to create it in a manually way)
Set SecLab = lab_serv.Create(I_LT_BAR_SECTION, new_secc)
Set SecData = SecLab.data
SecData.MaterialName = "S 355"
SecData.LoadFromDBase2 new_secc, SDName
lab_serv.Store SecLab
....The section is not properly created because it seems Robot doesn't find this new element in the user database, although the element (section) is saved in the database, this is like Robot doesn't know the database has new elements. The only way to generate this new section is re-starting Robot.
Is there some way or some API code to refresh the db in Robot and to avoid "close and open" Robot?
2. It seems not all parameters to define a section in a database are mandatory because then for the steel design checks, Robot calculates some of the mechanical properties by itself if the value is set as 0 in the database. For example the MSY and MSZ values (plastic section modulus).
Thanks in advance.
Solved! Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
Indeed, the database and the label server are two distinct entities.
To add a material to the database, you need to modify the XML file by creating a new entry.
It is preferable not to modify the core databases but rather create copies to store your commonly used materials.
To only add a new material to your project, you can use the CreateLike method and make the necessary changes to the copy of an existing material. Applying this material to your section then becomes straightforward.
Best Regards
Thanks a lot for your comments.
Maybe I'm explained wrong or maybe the code line
SecData.MaterialName = "S 355"
is causing confusion.
My intention is to create a new section or entry in the database (different from the existing ones), but different in geometry and mechanical properties (the material is not important). I am doing the process as you say through a new auxiliary user database, modifying the XML and creating a new entry. And everything is ok.
But the problem is Robot is only able to add the label for that new section if Robot is restarted, because it seems that it is not able to find that new section until the software is closed/opened.
I don't know if you have had a similar situation or if I am doing something wrong, or some special code to refresh the comunication between Robot and the database is necessary.
Thank you vey much.
have you tried
Dim RobApp As RobotApplication: If NotReady(RobApp) Then Exit Sub
Dim Materials As RobotMaterialDatabase
Set Materials = RobApp.Project.Preferences.Materials
If Materials.load("MaterialDBName") = 0 Then ' DB Material Not Found
MsgBox "The material database " & MaterialDBName & " could not be loaded, please check!", vbOKOnly + vbCritical, "Error"
Set RobApp = Nothing: Exit Sub
End If
Best Regards
at the end, try that :
Dim SectionsActive As RobotSectionDatabaseList
Set SectionsActive = RobApp.Project.Preferences.SectionsActive
' Location: C:\ProgramData\Autodesk\Structural\Common Data\xxxx\Data\Prof\
DBSectionName = "SNAME" 'FileName : SNAMEpro.xml
If SectionsActive.Add(DBSectionName) = 0 Then ' DBSectionName Not Found
MsgBox "The section database " & DBSectionName & " couldn't be loaded, please check!", vbOKOnly + vbCritical, "Error"
End If
Thanks for your suggestions but I can't achieve solve the problem, i think the issue is not related with "Materials" o database of materials. The line of your last post already was implemented in the code to get the database with the new section.
As you can see in the library section labels after calculation:
The red-framed label-sections were attempted to be generated just after storing the XML entries, as you can see they are wrong generated and the "I" symbol is not in the items.
The blue-framed label-sections were generated after close and open Robot project, with no problem to generate it when all sections are defined in the same XML database file.
The next function is in charge to generate the sections labels:
Sub generates_section_Robot(new_secc As Variant, SDName As String)
Dim robapp As RobotApplication, lab_serv As IRobotLabelServer
Set robapp = New RobotApplication
Dim newseccion As String, i As Integer
Dim SecLab As IRobotLabel, SecData As IRobotBarSectionData
robapp.Project.Preferences.SetCurrentDatabase IRobotDatabaseType.I_DT_SECTIONS, "WSP2"
Set lab_serv = robapp.Project.Structure.Labels
Dim SDL As IRobotSectionDatabaseList, RSD As IRobotSectionDatabase
Set SDL = robapp.Project.Preferences.SectionsActive
For i = 1 To SDL.count
If SDL.GetDatabase(i).name = SDName Then
Set RSD = SDL.GetDatabase(i)
End If
Next i
Dim Sections As IRobotNamesArray
Set Sections = RSD.GetAll
'/////Stephane's suggestion
Dim Materials As RobotMaterialDatabase, MaterialDBName As String
Set Materials = robapp.Project.Preferences.Materials
MaterialDBName = "EUROCODE"
If Materials.Load(MaterialDBName) = 0 Then ' DB Material Not Found
MsgBox "The material database " & MaterialDBName & " could not be loaded, please check!", vbOKOnly + vbCritical, "Error"
Set robapp = Nothing: Exit Sub
End If
'//////
If (Sections.Find(new_secc, 1) > 0) Then
Set SecLab = lab_serv.Create(I_LT_BAR_SECTION, new_secc)
Set SecData = SecLab.data
SecData.MaterialName = "S 355"
SecData.LoadFromDBase2 new_secc, SDName
lab_serv.Store SecLab
Else
MsgBox "Section " & new_secc & " does not exist in " + SDName + " database.", vbCritical, "Warning"
'curiosly this message doesn't jump!
End If
Set lab_serv = Nothing
Set SecData = Nothing
Set SecLab = Nothing
Set robapp = Nothing
End Sub
Maybe you can find something strange.
Thank you!
It seems that our posts have overlapped, I will study your last suggestion.
With your last code, it seems the database is founded, no message:
but in the label server the sections are wrong defined:
I the Robot is closed and opened, and running again the code, then the sections are fine:
the same thing is always happening.
Many thanks for your time and suggestions.
you should read this topic (the part where the label is duplicated [NewLabelData])
Best Regards
I was reading your post a few days ago and thought it had no direct relation to my issue, that it was a tag name definition issue, while my problem seems to be more of an internal connection issue between Robot and the XML database.
Anyway, I'll check it again and will do some testing with your code.
Thank you very much for your continued support.
Yes, I'm sure the purpose is not the same but the part of the code used to add sections to the database is similar.
Thank you very much for your time (and your code) but I can't get it to work.
The only way for Robot to know that there is a new entry in the XML is to restart it.
I seem to remember reading on the forum that even defining a section using "Section definition" in "Tools" requires close and re-opening Robot, I thought this kind of problem was already solved by now.
Thanks a lot for your time Stephan.
PS: It would be nice if the Robot development team could give an opinion on this.
Not sure, you need to inspect your database
I've attached mine, no need to restart
Sub CreateLabelSection()
Dim RobApp As RobotApplication: Set RobApp = New RobotApplication
DBSectionName = "ModS+"
If RobApp.Project.Preferences.SectionsActive.Add(DBSectionName) = 0 Then
Set RobApp = Nothing: Exit Sub
End If
Dim Labels As RobotLabelServer
Set Labels = RobApp.Project.Structure.Labels
Dim Label As RobotLabel, LabelData As IRobotBarSectionData
SectionName = "S+ 220x1.2"
Set Label = Labels.Create(I_LT_BAR_SECTION, SectionName)
Set LabelData = Label.Data
LabelData.LoadFromDBase2 SectionName, DBSectionName
Labels.Store Label
Set RobApp = Nothing
End Sub
Best Regards
Hi,
Thanks for your help and comments.
I'm not sure if you understood my need, maybe i didn't explain it well. The thing is that my XML is dynamic, that is, through code I create a new section (new entry) in the XML file and then, I want to generate the label for that section but it seems that Robot doesn't know that there is a new entry in the database.
For example, with your XML and your code:
- 1. First I have to modify your XML to do it "editable" by uncheck the CheckBox:
-2. Running your code for sectionname = "S+ 220x1.2" everything is OK, the label is well created
-3. But now I want to create by code a new XML entry (new section) and to create the corresponding label later. In this example with your XML file and to simplify the process I create the new entry manualy in the database editor.
-4. For it I copy the last element and paste in excel changing the name -> "S+ 500x5", and then paste in the XML file.
- 5. Closing the database editor, I can check in windows data that the XML file is saved, its oK.
- 6. But running your code with the new name -> sectionname = "S+ 500x5" the label is wrong defined:
-7. Even if i try to create the label manually, the new section is not showed in the combobox:
-8. And finally, closing&opening Robot and running your code again -> Everything is OK
I hope now you can understand my problem.
Thanks,
Pablo.
What you're describing is a manual process, so there's no problem with restarting the application, just as with a language change. However, I agree that the database could be updated without requiring a restart.
Why not use Microsoft XML Notepad instead? You can duplicate rows and assign properties easily.
If the process requires modifying sections during the design phase, I recommend creating a patch to include the updated sections.
Best Regards
Not mentioned, but another aspect of your question is the possibility of restarting.
Sub SaveAndQuitProject(ByRef ProjectName As String)
Dim RobApp As RobotApplication: Set RobApp = New RobotApplication
Ok = RobApp.Visible = -1 And RobApp.Project.IsActive = -1
If Not Ok Then
Set RobApp = Nothing: Exit Sub
End If
With RobApp: ProjectName = .Project.Filename: .Project.Save: .Project.Close: .Quit I_QO_SAVE_CHANGES: End With
Set RobApp = Nothing
End Sub
Sub OpenAndLoadProject(ProjectName As String)
On Error GoTo ErrorHandler
Dim RobApp As RobotApplication: Set RobApp = New RobotApplication
With RobApp
.Visible = -1
With .Project
'.IsActive = -1 ' <<< Read only
.Open ProjectName
End With
End With
Set RobApp = Nothing: Exit Sub
ErrorHandler:
MsgBox "Error opening the project: " & Err.Description, vbCritical, "COM Error"
If Not RobApp Is Nothing Then Set RobApp = Nothing
End Sub
Sub Restart()
Dim ProjectName As String
Call SaveAndQuitProject(ProjectName)
If Len(ProjectName) > 0 Then Call OpenAndLoadProject(ProjectName)
End Sub
Best Regards
Right, I was considering it doiing some testing, thank you very much for your help.
Regarding my second question from my first post, do you have any information about it?
2. It seems not all parameters to define a section in a XML database are mandatory because then for the steel design checks, Robot calculates some of the mechanical properties by itself if the value is set as 0 in the database. For example the MSY and MSZ values (plastic section modulus).
Would it be ok for example to not add MSY and MSZ values in the XML and have Robot calculate them in section checks? ...Or could it be weird or dangerous.
Thank you!!
For MSY and MSZ, it's difficult to give an opinion without knowing both the type of calculation and the section, the thicknesses, and the steel grade. However, some values are fully calculated and don't need to be defined in the database. For new libraries, all these questions are welcome, and I even believe the XML structure could be improved.
Best Regards
Can't find what you're looking for? Ask the community or share your knowledge.