Set Material through API

Set Material through API

Anonymous
Not applicable
1,858 Views
9 Replies
Message 1 of 10

Set Material through API

Anonymous
Not applicable

Hello!

I have seen this post https://forums.autodesk.com/t5/robot-structural-analysis-forum/vba-excel-macro-for-any-object-geomet... very very useful, thanks to @Rafal.Gaweda.

I would like to have inside that API a tool in order to get the "Material Definition" information inside the excel, then changing or adding a new material still inside excel, then update everything into RSA.

 

Thank you in advance

 

 

CANC.JPG 

0 Likes
Accepted solutions (1)
1,859 Views
9 Replies
Replies (9)
Message 2 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous

 

I am attaching two example which should allow you to start writing your own macro.



Rafal Gaweda
Message 3 of 10

Anonymous
Not applicable

thanks @Rafal.Gaweda for answering,

but I get the following error when I try to change material's name

CANC.JPG

0 Likes
Message 4 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous

 

As you may see from your screen shot, this macro can Get material and Update it (= update its  properties) , not for creating new one (new one = new name).



Rafal Gaweda
0 Likes
Message 5 of 10

Anonymous
Not applicable

How can I create new one material?

0 Likes
Message 6 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous

 

Example code:

 

Private Sub CommandButton1_Click()


Dim RobApp As New RobotApplication
Dim MatLabel As RobotLabel
Dim MatData As RobotMaterialData


    
    Set MatLabel = RobApp.Project.Structure.Labels.Create(I_LT_MATERIAL, "MyMaterial")
    
    Set MatData = MatLabel.Data
    MatData.E = 200000000
    MatData.Kirchoff = 3000000
    MatData.RO = 400000
    MatData.NU = 5000000
    RobApp.Project.Structure.Labels.Store MatLabel


End Sub


Rafal Gaweda
Message 7 of 10

Anonymous
Not applicable

thanks @Rafal.Gaweda for answering again,

but I'm still not able to import the material edited (both name and properties) from Excel to RSA through API

0 Likes
Message 8 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous

 

Screen shot below

 

mymaterial.jpg



Rafal Gaweda
Message 9 of 10

Anonymous
Not applicable

Yes you are right, but is it possible to have it in the "concrete" window instead having it in "all" . 

Instead putting "my material" inside the macro, could be nice to import the name of the material from the cell! 

The macro imports directly the values into RSA, but it doesn't import from the cell's value like here https://forums.autodesk.com/t5/robot-structural-analysis-forum/vba-excel-macro-for-any-object-geomet....

To summarize the issue, Is it possible to import name and properties from excel cell value into RSA?

0 Likes
Message 10 of 10

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution
Dear @Anonymous

is it possible to have it in the "concrete" window instead having it in "all" . 

 


Add

 

 

MatData.Type = I_MT_CONCRETE



Instead putting "my material" inside the macro, could be nice to import the name of the material from the cell! 

 

Could you do a small effort from your side and try yourself? 

I showed you all pieces. Just use them in the way you want.



Rafal Gaweda