Hello,
I am student and I am working on a project with a company. I came to a dead end and I need help with VBA.
Basically what I am doing is I have the model ready and done all calculations by the regular GUI. I want to change stiffness values of spring supports already modelled into robot, by new stiffness's which I have in my excel file. My program VBA code and API on Robot runs and shows no errors. When running the program behaves as if it is accessing Robot every time correctly but the value of stiffness doesn't get updated according to what I have in excel. The value stays same as old.
I have attached a screenshot showing the part of the code making changes in the Robot directory from excel file. However I think I am missing some part of the code.
Further, the installation of the software seems fine as well. Please help me!
Thanks,
Solved! Go to Solution.
Solved by Stephane.kapetanovic. Go to Solution.
hi @darren.cosh
Difficult to say why, you do not seem to have communicated the part where the rigidity of the support is modified.
Best Regards
Dim SupLabel As RobotLabel
With RobApp.Project.Structure.Labels
Set SupLabel = .Create(I_LT_SUPPORT, "MySupport")
With SupLabel.Data
.KX = 7000: .KY = 8000: .KZ = 9000
End With
.Store SupLabel
End With
That is where I am confused at. I have to modify the KZ of the support again from excel, but this is not included in the code.
I have attached a screenshot of the code making some amendments adding the new KZ data into the Robot support table. However, I do not know if I have to store the label again, as I do not want to change them. I am getting a miss match error on the highlighted line in the attached error screenshot for the same code.
Is there somewhere I can look at the object database to know which specific label I have to use to pick/change an attribute of the table in supports?
I want to change KZ of all supports, with everyone having a different value and name. Names are already added and I am changing the value.
Thanks,
hi @darren.cosh
so no need to iterate over the nodes that have these supports, you have to do it on the support labels from their names and change them one by one.
Dim Coef As Double
Coef = 0.8
Dim LabelCollection As RobotLabelCollection
Set LabelCollection = RobApp.Project.Structure.Labels.GetMany(I_LT_SUPPORT)
For i = 1 To LabelCollection.Count
Set SupLabel = LabelCollection.Get(i)
If Left(SupLabel.Name, 7) = "Support_" Then
With SupLabel.Data: .KZ = .KZ * Coef: End With
RobApp.Project.Structure.Labels.Store SupLabel
End If
Next i
Best Regards
hi @darren.cosh
this is an example, I don't know your case precisely, take into account the way to iterate on the labels rather than on the nodes. Rather than a coefficient, you will undoubtedly opt for a value from your sheet.
What you need to do is list all the different labels (one per node if needed) and change them all to whatever value you want.
Best Regards
Can't find what you're looking for? Ask the community or share your knowledge.