Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA loads - API

44 REPLIES 44
SOLVED
Reply
Message 1 of 45
Anonymous
3307 Views, 44 Replies

VBA loads - API

I create a sub which define loads on a pannel but it's doesn't work.

 

Can you have a look ?

 

 

 

Public typecharge As String
Public casdecharge As String
Public valeurcharge As Double
Public x_1 As Double
Public y_1 As Double
Public z_1 As Double
Public x_2 As Double
Public y_2 As Double
Public z_2 As Double
Public x_3 As Double
Public y_3 As Double
Public z_3 As Double
Public x_4 As Double
Public y_4 As Double
Public z_4 As Double

 

 

 

Public Sub charges()
'trotoirs
typecharge = I_CN_PERMANENT
casdecharge = "Equipements"
valeurcharge = 5.5
x_1 = 0.000
y_1 = 0.000
z_1 = 0.000
x_2 = 75.480
y_2 = 0.000
z_2 = 0.000
x_3 = 76.143
y_3 = 1.600
z_3 = 0.000
x_4 = 0.663
y_4 = 1.600
z_4 = 0.000
Call chargement_panneau_contour

End Sub

 

 

Sub chargement_panneau_contour()

    Dim cas As RobotSimpleCase
    Dim recs As RobotLoadRecordMngr
    Dim rec_1 As RobotLoadRecordInContour
    Set cas = robapp.Project.Structure.Cases.CreateSimple(robapp.Project.Structure.Cases.FreeNumber, _
casdecharge, typecharge, I_CAT_STATIC_LINEAR)
    Set recs = cas.Records
    
' pression uniforme horizontale appliquée au contour
' définition des contours
    i = recs.New(I_LRT_IN_CONTOUR)
    
' création d'une nouvel enregistrement
    Set rec_1 = recs.Get(i)
    
' définition du plan de charge
    rec_1.Objects.FromText "1"
    rec_1.SetValue I_ICRV_PX1, 0
    rec_1.SetValue I_ICRV_PY1, 0
    rec_1.SetValue I_ICRV_PZ1, -valeurcharge
    rec_1.SetValue I_ICRV_PX2, 0#
    rec_1.SetValue I_ICRV_PY2, 0#
    rec_1.SetValue I_ICRV_PZ2, -valeurcharge
    rec_1.SetValue I_ICRV_PX3, 0#
    rec_1.SetValue I_ICRV_PY3, 0#
    rec_1.SetValue I_ICRV_PZ3, -valeurcharge
    
    ' sens de projection des efforts
    rec_1.SetValue I_ICRV_PROJECTION, 1

    ' nombre de points composant le contour
    rec_1.SetValue I_ICRV_NPOINTS, 4
    rec_1.SetValue I_ICRV_LOCAL, 0

    ' définition des points sur le panneau
    rec_1.SetPoint 1, 0, 0, 0
    rec_1.SetPoint 2, 1, 1, 0
    rec_1.SetPoint 3, 1, 0, 0

    rec_1.SetContourPoint 1, x_1, y_1, z_1
    rec_1.SetContourPoint 2, x_2, y_2, z_2
    rec_1.SetContourPoint 3, x_3, y_3, z_3
    rec_1.SetContourPoint 4, x_4, y_4, z_4
    
    rec_1.SetVector 0, 0, 1

    Set recs = Nothing
    Set rec_1 = Nothing
    Set cas = Nothing
  
End Sub

 

44 REPLIES 44
Message 21 of 45
Rafal.Gaweda
in reply to: Anonymous


mateaus wrote:

I have created a convoy which name is "TS".

 

If I understand your macro, I just have to replace "PN1030" by "TS" :

 

VData.LoadFromDBase "Pojazd S - klasa E", "TS"

 

I have created a catalog to save my convoy. I don't know how to save it otherwise.

 

catalog

 

Will it working with your macro ?

 

 ' assign vehicle to case

Set VLabel = Robapp.Project.Structure.Labels.Create(I_LT_VEHICLE, "your_vehicle_name") select vehicle name
Set VData = VLabel.Data


VData.LoadFromDBase "your_vehicle_name", "PRO"  ' PRO is the name of your database
Robapp.Project.Structure.Labels.Store VLabel

Cas.Vehicle = "your_vehicle_name"

 



Rafal Gaweda
Message 22 of 45
Rafal.Gaweda
in reply to: Anonymous

I would like to create a convoy's library in order to share it whith my colleagues but I don't know where it is save in the computer and what I have to copy in their computer.



The database file is created in:

 

"c:\Users\<USER>\AppData\Roaming\Autodesk\Structural\Common Data\2012" 

 

as V_...xml file. In your case V_PRO.xml file

copy it to similar location on other computers.



Rafal Gaweda
Message 23 of 45
Anonymous
in reply to: Rafal.Gaweda


@Anonymous_Adsk wrote:

I would like to create a convoy's library in order to share it whith my colleagues but I don't know where it is save in the computer and what I have to copy in their computer.



The database file is created in:

 

"c:\Users\<USER>\AppData\Roaming\Autodesk\Structural\Common Data\2012" 

 

as V_...xml file. In your case V_PRO.xml file

copy it to similar location on other computers.


It doesn't work. I have copied the file but there is nothing when I open Robot : 

library

 

 

Message 24 of 45
Rafal.Gaweda
in reply to: Anonymous

Add this database to project:

 

veh.jpg



Rafal Gaweda
Message 25 of 45
Anonymous
in reply to: Rafal.Gaweda

Ok is it possible to do it automaticaly. Is there a file default to copy ?

Message 26 of 45
Rafal.Gaweda
in reply to: Anonymous



Ok is it possible to do it automaticaly. Is there a file default to copy ?


So you already know where the database file is located.

Add database to job preferences as shown in previous post, then save preferences:

File named ...cov will be saved in path which can be checked in the field marked by green rectagle below

Then copy it to different computers to similar folder, besides copying database file.

 

cov.jpg



Rafal Gaweda
Message 27 of 45
Anonymous
in reply to: Rafal.Gaweda


@Anonymous_Adsk wrote:

Creating moving load case with vehicle loaded from database:

 

Dim Cas As RobotMobileCase
Dim Route As RobotMobileCaseRoute
Dim VData As RobotVehicleData

 

 ' route is a polyline  - creating polyline here

Dim PlineGeometry As RobotGeoPolyline
Set PlineGeometry = Robapp.CmpntFactory.Create(I_CT_GEO_POLYLINE)


Dim Segment As RobotGeoSegment
Dim Object As RobotObjObject

 

 ' create as many segments (= characteristic points of polyline) as you like in the way shown below

Set Segment = Robapp.CmpntFactory.Create(I_CT_GEO_SEGMENT_LINE)
Segment.P1.Set 0, 2, 0

PlineGeometry.Add Segment
PlineGeometry.Initialize

 

Set Segment = Robapp.CmpntFactory.Create(I_CT_GEO_SEGMENT_LINE)
Segment.P1.Set 10, 2, 0

PlineGeometry.Add Segment
PlineGeometry.Initialize

 

RouteNumber = 13

 

 ' creating object from polyline

Set Object = Robapp.Project.Structure.Objects.Create(RouteNumber)
Object.Main.Geometry = PlineGeometry
Object.Initialize
Object.Update

 

 ' creating moving load case 

Set Cas = Robapp.Project.Structure.Cases.CreateMobile(Robapp.Project.Structure.Cases.FreeNumber, "Moving Load Case", I_CN_PERMANENT)

 

 ' assigning route and route parameters to case
Set Route = Cas.GetRoute

Route.Geometry = RouteNumber

 

Dim Fac As RobotMobileCaseSegmentFactors
Set Fac = Route.GetFactors(1)
Fac.VL = 1
Fac.VR = 1
Route.SetFactors 1, Fac


Route.LoadDirection.Set 0, 0, -1
Route.Step = 1
Cas.SetRoute Route

 

 ' assign vehicle to case

Set VLabel = Robapp.Project.Structure.Labels.Create(I_LT_VEHICLE, "Pojazd S - klasa E") ' select vehicle name
Set VData = VLabel.Data


VData.LoadFromDBase "Pojazd S - klasa E", "PN1030"  ' select vehicle name and database name
Robapp.Project.Structure.Labels.Store VLabel

Cas.Vehicle = "Pojazd S - klasa E" ' assign vehicle to case


I've modified the macro but it's not working if I want to select a case which already exist :

 

'définit les cas de charges
Dim Loads As RobotCaseServer
Set Loads = Robapp.Project.Structure.Cases

Dim Cas As RobotMobileCase
Set Cas = Loads.Get(nocasdecharge)

 

Sub generation_charges_roulantes()

'définit les cas de charges
Dim Loads As RobotCaseServer
Set Loads = Robapp.Project.Structure.Cases

Dim Cas As RobotMobileCase
Dim Route As RobotMobileCaseRoute
Dim VData As RobotVehicleData
 
 
 ' route is a polyline  - creating polyline here
Dim PlineGeometry As RobotGeoPolyline
Set PlineGeometry = Robapp.CmpntFactory.Create(I_CT_GEO_POLYLINE)

Dim Segment As RobotGeoSegment
Dim Object As RobotObjObject
 
 ' create as many segments (= characteristic points of polyline) as you like in the way shown below
Set Segment = Robapp.CmpntFactory.Create(I_CT_GEO_SEGMENT_LINE)
Segment.P1.Set x_1, y_1, z_1
PlineGeometry.Add Segment
PlineGeometry.Initialize
 
Set Segment = Robapp.CmpntFactory.Create(I_CT_GEO_SEGMENT_LINE)
Segment.P1.Set x_2, y_2, z_2
PlineGeometry.Add Segment
PlineGeometry.Initialize
 
 ' creating object from polyline
Set Object = Robapp.Project.Structure.Objects.Create(RouteNumber)
Object.Main.Geometry = PlineGeometry
Object.Initialize
Object.Update
 
 ' creating moving load case
Set Cas = Loads.Get(nocasdecharge)
'Set Cas = Robapp.Project.Structure.Cases.CreateMobile(Robapp.Project.Structure.Cases.FreeNumber, "Moving Load Case", I_CN_PERMANENT)
 
 ' assigning route and route parameters to case
Set Route = Cas.GetRoute
Route.Geometry = RouteNumber
Route.LoadDirection.Set 0, 0, -1
'définit le pas (non paramétré)
Route.Step = 1
Cas.SetRoute Route
 
 ' assign vehicle to case
Set VLabel = Robapp.Project.Structure.Labels.Create(I_LT_VEHICLE, Vehicle_name) ' select vehicle name
Set VData = VLabel.Data

'Pour charger un vehicule enregistrer dans la bibliothèque (cmd non utilisé)
'VData.LoadFromDBase Vehicle_name, "PRO"  ' PRO is the name of your database ; select vehicle name and database name
Robapp.Project.Structure.Labels.Store VLabel

Cas.Vehicle = Vehicle_name ' assign vehicle to case

End Sub

 

Message 28 of 45
Rafal.Gaweda
in reply to: Anonymous


Mateaus 

I've modified the macro but it's not working if I want to select a case which already exist :

 

It is not possible. Moving load case is different case type, even if you make it manually in Robot you do it in different way.  Do it this way:

- get simple case number

- delete this simple case

- create moving load case with this number



Rafal Gaweda
Message 29 of 45
Anonymous
in reply to: Rafal.Gaweda

When I generate the moving loads with API even if I load from data or create a new one I can't see the value of loads in the view.

 

Is there a solution ?

 

view moving loads

Message 30 of 45
Rafal.Gaweda
in reply to: Anonymous


mateaus wrote:

When I generate the moving loads with API even if I load from data or create a new one I can't see the value of loads in the view.

 

Add this green code. If loads are not displayed please run Model Generation or Calculations

 

 ' assigning route and route parameters to case
Set Route = Cas.GetRoute
Route.Geometry = RouteNumber

Dim Fac As RobotMobileCaseSegmentFactors
Set Fac = Route.GetFactors(1)
Fac.VL = 1
Fac.VR = 1
Route.SetFactors 1, Fac

 

Route.LoadDirection.Set 0, 0, -1
'définit le pas (non paramétré)
Route.Step = 1
Cas.SetRoute Route

 



Rafal Gaweda
Message 31 of 45
Anonymous
in reply to: Rafal.Gaweda

Ok it's working,

 

Do you have an example of VBA code to create a trapezoidal load (2p) on a bar like this one ?

 

trapez load 2p

Message 32 of 45
Rafal.Gaweda
in reply to: Anonymous

Set Recs = SimpleCase.Records

I = Recs.New(I_LRT_BAR_TRAPEZOIDALE)
Set Rec = Recs.Get(I)
Rec.Objects.FromText BarNumber


 Rec.SetValue I_BTRV_LOCAL, -1 ' or global


Rec.SetValue I_BTRV_RELATIVE, -1 ' or real

 

'Select Case Direction

'Case "fx"
Rec.SetValue I_BTRV_PX1, value_x1
Rec.SetValue I_BTRV_X1, pos_x1
Rec.SetValue I_BTRV_PX2, value_x2
Rec.SetValue I_BTRV_X2, pos_x2
'Case "fy"
Rec.SetValue I_BTRV_PY1, value_y1
Rec.SetValue I_BTRV_X1, pos_x1
Rec.SetValue I_BTRV_PY2, value_y2
Rec.SetValue I_BTRV_X2, pos_x2
'Case "fz"
Rec.SetValue I_BTRV_PZ1, value_z1
Rec.SetValue I_BTRV_X1, pos_x1
Rec.SetValue I_BTRV_PZ2, value_z2
Rec.SetValue I_BTRV_X2, pos_x2
'End Select



Rafal Gaweda
Message 33 of 45
Anonymous
in reply to: Rafal.Gaweda

and this one : Load on bar ?

Message 34 of 45
Rafal.Gaweda
in reply to: Anonymous


mateaus wrote:

and this one : Load on bar ?


 

Set Recs = SimpleCase.Records

I = Recs.New(I_LRT_BAR_FORCE_CONCENTRATED)
Set Rec = Recs.Get(I)
Rec.Objects.FromText BarNumber

 Rec.SetValue I_BFCRV_LOC, -1 ' or global

 Rec.SetValue I_BFCRV_REL, -1 ' or real

'Select Case Direction
'Case "fx"
Rec.SetValue I_BFCRV_FX, value
'Case "fy"
Rec.SetValue I_BFCRV_FY, value
'Case "fz"
Rec.SetValue I_BFCRV_FZ, value
'Case "mx"
Rec.SetValue I_BFCRV_CX, value
'Case "my"
Rec.SetValue I_BFCRV_CY, value
'Case "mz"
Rec.SetValue I_BFCRV_CZ, value
'End Select

Rec.SetValue I_BFCRV_X, pos_x  'position  

 

I have not used all properties (all shown below) of this kind of load in the example above.

If you need them use them accordingly.

 

vbaconcload.jpg



Rafal Gaweda
Message 35 of 45
Anonymous
in reply to: Rafal.Gaweda

Hi,

 

I would like to program linear supports :

 

appuis linéaires.PNG

 

Can you give me a code to do that with VBA ?

Message 36 of 45
Rafal.Gaweda
in reply to: Anonymous

Take a look at reservior_test.xls example you have.

 

 Dim monobjet As RobotObjObject
   Dim moncote As RobotObjEdge
   Dim sup As IRobotLabel
   Dim sup_data As IRobotNodeSupportData
   
   Set sup = robapp.Project.Structure.Labels.Create(I_LT_SUPPORT, "mon_appuis_1")
   Set sup_data = sup.Data
 
 ' definition des appuis
 
    sup_data.SetFixed I_NSFD_UX, True
    sup_data.SetFixed I_NSFD_UY, False
    sup_data.SetFixed I_NSFD_UZ, False
    sup_data.SetFixed I_NSFD_RX, False
    sup_data.SetFixed I_NSFD_RY, True
    sup_data.SetFixed I_NSFD_RZ, True

   robapp.Project.Structure.Labels.Store sup
      
    Set monobjet = robapp.Project.Structure.Objects.Get(2)
    Set moncote = monobjet.Main.Edges.Get(4)
    moncote.SetLabel I_LT_SUPPORT, "mon_appuis_1"
    monobjet.Update
      

 



Rafal Gaweda
Message 37 of 45
Anonymous
in reply to: Rafal.Gaweda


@Anonymous_Adsk wrote:

Take a look at reservior_test.xls example you have.

 

 Dim monobjet As RobotObjObject
   Dim moncote As RobotObjEdge
   Dim sup As IRobotLabel
   Dim sup_data As IRobotNodeSupportData
   
   Set sup = robapp.Project.Structure.Labels.Create(I_LT_SUPPORT, "mon_appuis_1")
   Set sup_data = sup.Data
 
 ' definition des appuis
 
    sup_data.SetFixed I_NSFD_UX, True
    sup_data.SetFixed I_NSFD_UY, False
    sup_data.SetFixed I_NSFD_UZ, False
    sup_data.SetFixed I_NSFD_RX, False
    sup_data.SetFixed I_NSFD_RY, True
    sup_data.SetFixed I_NSFD_RZ, True

   robapp.Project.Structure.Labels.Store sup
      
    Set monobjet = robapp.Project.Structure.Objects.Get(2)
    Set moncote = monobjet.Main.Edges.Get(4)
    moncote.SetLabel I_LT_SUPPORT, "mon_appuis_1"
    monobjet.Update
      

 


Ok I saw the file reservoir but my macro is not working. I have this error message :

 

message erreur appuis.PNG

 

erreur macro ligne appui.PNG

 

The variable moncote is declared but it's not work anyway.

 

I don't know how to solv it ?

Message 38 of 45
Rafal.Gaweda
in reply to: Anonymous

Do you have object no17 in model? Has it edge no 3 ?

If so send me model and macro.



Rafal Gaweda
Message 39 of 45
Anonymous
in reply to: Rafal.Gaweda

Macro :

 

Public Sub appuis_robot()

 Dim monobjet As RobotObjObject
   Dim moncote As RobotObjEdge
   Dim sup As IRobotLabel
   Dim sup_data As IRobotNodeSupportData
   
   Set sup = Robapp.Project.Structure.Labels.Create(I_LT_SUPPORT, "appuis_entretoises")
   Set sup_data = sup.Data
 
 ' definition des appuis
 
    sup_data.SetFixed I_NSFD_UX, True
    sup_data.SetFixed I_NSFD_UY, False
    sup_data.SetFixed I_NSFD_UZ, False
    sup_data.SetFixed I_NSFD_RX, False
    sup_data.SetFixed I_NSFD_RY, True
    sup_data.SetFixed I_NSFD_RZ, True

   Robapp.Project.Structure.Labels.Store sup
      
    Set monobjet = Robapp.Project.Structure.Objects.Get(3)
    Set moncote = monobjet.Main.Edges.Get(17)
    moncote.SetLabel I_LT_SUPPORT, "appuis_entretoises"
    monobjet.Update

   Robapp.Project.Structure.Labels.Store sup
    Set sup_data = Nothing
    Set sup = Nothing
    Set monobjet = Nothing
    Set moncote = Nothing

End Sub

 

Message 40 of 45
Rafal.Gaweda
in reply to: Anonymous

You have object 3 edge 17.

 

Object 17 , edge 3 - below

 

Set monobjet = RobApp.Project.Structure.Objects.Get(17)
Set moncote = monobjet.Main.Edges.Get(3)



Rafal Gaweda

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report