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: 

Extreamly slow API cals with Robot 2021

5 REPLIES 5
Reply
Message 2 of 6
jokiller70
795 Views, 5 Replies

Extreamly slow API cals with Robot 2021

I have been using the attached code for many years, but with Robot 2021 it is extreamly slow.

 

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Show()

        'On Error Resume Next

        Dim screenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim screenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Me.Left = screenWidth / 2
        Me.Top = screenHeight / 2


        Dim KnlL As RobotNonlinearLink = Nothing
        Dim nlLP As RobotOM.IRobotNonlinearLinkParams = Nothing
        Dim nlL As RobotOM.RobotNonlinearLink = Nothing
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim db As Database = doc.Database

        Dim I_CT_EXTREME_PARAMS As Integer = 42
        Dim I_EVT_STRESS_BAR_SMAX As Integer = 171
        Dim I_OT_BAR As Integer = 1
        Dim I_OT_CASE As Integer = 2

        Dim knutmaxxx As Double
        Dim knutmaxxy As Double
        Dim knutmaxxz As Double
        Dim knutmaxyx As Double
        Dim knutmaxyy As Double
        Dim knutmaxyz As Double
        Dim knutmaxzx As Double
        Dim knutmaxzy As Double
        Dim knutmaxzz As Double

        Dim knutmaxx As Double
        'Dim knutmaxxnod As Integer
        'Dim knutmaxxstart As Integer
        Dim knutmaxy As Double
        'Dim knutmaxynod As Integer
        'Dim knutmaxystart As Integer
        Dim knutmaxz As Double
        Dim robapp As IRobotApplication = Nothing
        robapp = New RobotApplication

        Using dl As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim btr As BlockTableRecord = TryCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
                Dim startpoint(0 To 2) As Double
                Dim startpointstress(0 To 2) As Double
                Dim endpoint(0 To 2) As Double

                Dim psto As New PromptStringOptions(vbLf & "filnamn att läsa in: ")
                psto.AllowSpaces = True
                psto.DefaultValue = "c:\calc.rtd"
                Dim stres As PromptResult
                stres = ed.GetString(psto)
                If stres.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim s2dpath As String = stres.StringResult

                Dim psto2 As New PromptStringOptions(vbLf & "path to Robot blocks: ")
                psto2.AllowSpaces = True
                psto2.DefaultValue = "C:\Dropbox (MonZon Group)\Utveckling med Berth\robot blocks\"  'old block
                Dim stres2 As PromptResult
                stres2 = ed.GetString(psto2)
                If stres2.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim robpath As String = stres2.StringResult

                Dim psto3 As New PromptStringOptions(vbLf & "iterationssteg")
                psto3.AllowSpaces = True
                psto3.DefaultValue = "10"  'old block
                Dim stres3 As PromptResult
                stres3 = ed.GetString(psto3)
                If stres3.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim steg As Integer = stres3.StringResult
                Dim tm As Transaction =
                            db.TransactionManager.StartTransaction()
                Using tm
                    Dim st As TextStyleTable = CType(tm.GetObject(
                                db.TextStyleTableId,
                                OpenMode.ForWrite, False),
                                                 TextStyleTable)
                    Dim str As TextStyleTableRecord =
                                        New TextStyleTableRecord()
                    str.Name = "MyStyle"
                    st.Add(str)

                    'Following are properties to set by default,
                    'you can also modify them

                    'str.FileName = "txt.shx"
                    'str.PriorSize = 0.2               
                    'str.ObliquingAngle = 0.0
                    'str.XScale = 1.0
                    'str.TextSize = 0.0
                    'str.IsVertical = False
                    'str.IsShapeFile = False

                    'using the font descriptor to set the new font style
                    'Imports Autodesk.AutoCAD.GraphicsInterface
                    str.FileName = "STANDARD.shx"
                    tm.AddNewlyCreatedDBObject(str, True)

                    'make as current
                    db.Textstyle = str.ObjectId
                    tm.Commit()
                End Using

                If robapp.Project.IsActive = True Then
                Else
                    robapp.Project.Open(s2dpath)
                End If
                'MsgBox("inget öppet i Robot?")
                'Me.Close()
                'Exit Sub

                robapp.Visible = True

                'Dim force_serv As IRobotBarForceServer = robapp.Project.Structure.Results.Bars.Forces
                Dim fe_serv As IRobotBarStressServer = robapp.Project.Structure.Results.Bars.Stresses
                Dim REV As RobotExtremeValue
                Dim Params As RobotExtremeParams
                Params = New RobotExtremeParams
                Params = robapp.CmpntFactory.Create(I_CT_EXTREME_PARAMS)
                Params.BarDivision = 30
                Dim rs As RobotSelection
                rs = robapp.Project.Structure.Selections.CreateFull(I_OT_BAR)
                Dim rsc As RobotSelection
                rsc = robapp.Project.Structure.Selections.CreateFull(I_OT_CASE)

                Dim casecol As RobotCaseCollection = robapp.Project.Structure.Cases.GetAll

                Dim j As Integer = 1
                Do While (j <= casecol.Count)
                    Dim rc As IRobotCase = casecol.Get(j)
                    Dim AT As IRobotCaseAnalizeType = rc.AnalizeType
                    If AT = IRobotCaseAnalizeType.I_CAT_STATIC_NONLINEAR Then
                    Else
                        If robapp.Project.Structure.Cases.Exist(j) = True Then
                            robapp.Project.Structure.Cases.SetAuxiliary(j, True)
                        End If
                    End If
                    j = (j + 1)
                Loop

                Params.Selection.Set(I_OT_BAR, rs)
                Params.Selection.Set(I_OT_CASE, rsc)
                Params.ValueType = I_EVT_STRESS_BAR_SMAX

                REV = robapp.Project.Structure.Results.Extremes.MaxValue(Params)
                Dim stresstemp As Double = Math.Abs(CInt(REV.Value / 100000) / 10)
                Label2.Text = Math.Abs(CInt(REV.Value / 100000) / 10)

                Params.ValueType = IRobotExtremeValueType.I_EVT_STRESS_BAR_SMIN
                REV = robapp.Project.Structure.Results.Extremes.MinValue(Params)
                Label3.Text = Math.Abs(CInt(REV.Value / 100000) / 10)

                If stresstemp > Math.Abs(CInt(REV.Value / 100000) / 10) Then
                    Params.ValueType = I_EVT_STRESS_BAR_SMAX
                    REV = robapp.Project.Structure.Results.Extremes.MaxValue(Params)
                End If

                Dim ddd As Double = Math.Abs(CInt(REV.Value / 100000) / 10)
                Dim cas_num As Integer = REV.Case
                Dim var As Double = REV.Position
                Dim vilkenbar As Integer = REV.Bar

                Dim res_fx As Double, res_fz As Double, res_fy As Double, res_mx As Double, res_my As Double, res_mz As Double

                Dim serv As IRobotReactionServer = robapp.Project.Structure.Results.Nodes.Reactions
                Dim knutflytt As RobotNodeDisplacementServer = robapp.Project.Structure.Results.Nodes.Displacements
                Dim NodeServer As RobotNodeServer = robapp.Project.Structure.Nodes
                Dim bar_col As IRobotCollection = robapp.Project.Structure.Bars.GetAll()
                Dim value As RobotOM.IRobotDisplacementData
                Dim value2 As RobotOM.IRobotDisplacementData
                Dim deflect As RobotBarDeflectionServer = Nothing
                Dim deflect1 As RobotBarDeflectionData
                Dim deflect2 As RobotBarDeflectionData
                Dim deplace As RobotBarDisplacementServer = Nothing
                deflect = robapp.Project.Structure.Results.Bars.Deflections
                deplace = robapp.Project.Structure.Results.Bars.Displacements

                Dim force_serv As IRobotBarForceServer
                Dim data1 As IRobotBarForceData
                force_serv = robapp.Project.Structure.Results.Bars.Forces

                Dim dflect1(0 To 2) As Double
                Dim dflect2(0 To 2) As Double
                Dim mtx(3, 3) As Double
                Dim maxnedböj As Double
                'Dim maxsstress As Double
                Dim maxnedböjx As Autodesk.AutoCAD.Geometry.Point3d
0:
                Dim maxmy As Double = 0
                Dim mymaxvar(0 To 2) As Double

                Dim RLabel As RobotLabel
                Dim RelData As RobotBarReleaseData
                Dim I_LT_BAR_RELEASE As Integer = 4
                'If robapp.Project.Structure.Bars.FreeNumber = 0 Then
                'MsgBox("Inget öppet i Robot?")
                'End Sub
                'End If
                If bar_col.Count = 0 Then
                    MsgBox("Inget öppet i Robot?")
                    Me.Close()
                    Exit Sub
                End If
                'If vilkenbar = 0 Then
                'MsgBox("Inget beräkning?")
                'robapp.Visible = True
                'Me.Close()
                'Exit Sub
                'End If

                Dim Bar As RobotBar = robapp.Project.Structure.Bars.Get(vilkenbar)
                Dim RNode As RobotNode = NodeServer.Get(Bar.StartNode)
                Dim RNode2 As RobotNode = NodeServer.Get(Bar.EndNode)
                Dim knutvärde As RobotOM.IRobotDisplacementData = knutflytt.Value(Bar.StartNode, cas_num)
                Dim knutvärde2 As RobotOM.IRobotDisplacementData = knutflytt.Value(Bar.EndNode, cas_num)
                deflect1 = deflect.Value(vilkenbar, cas_num, var)

                'startpointstress(0) = knutvärde.UX * 10 + RNode.X + dflect2(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * var
                'startpointstress(1) = knutvärde.UY * 10 + RNode.Y + dflect2(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * var
                'startpointstress(2) = knutvärde.UZ * 10 + RNode.Z + dflect2(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * var

                startpointstress(0) = RNode.X + knutvärde.UX * 10 + (RNode2.X - RNode.X) * var + knutvärde.UX * 10 + (knutvärde2.UX * 10 - knutvärde.UX * 10) * var + deflect1.UX * 10
                startpointstress(1) = RNode.Y + knutvärde.UY * 10 + (RNode2.Y - RNode.Y) * var + knutvärde.UY * 10 + (knutvärde2.UY * 10 - knutvärde.UY * 10) * var + deflect1.UY * 10
                startpointstress(2) = RNode.Z + knutvärde.UZ * 10 + (RNode2.Z - RNode.Z) * var + knutvärde.UZ * 10 + (knutvärde2.UZ * 10 - knutvärde.UZ * 10) * var + deflect1.UZ * 10

                For i As Integer = 1 To bar_col.Count
                    'System.Windows.Forms.Application.DoEvents()

                    Me.Label1.Text = i & " av:" & bar_col.Count
                    Me.Text = i & ":" & bar_col.Count
                    Bar = bar_col.Get(i)
                    Dim bar_num As Long = Bar.Number
                    Dim iterationer As Integer = Bar.Length / 0.3 * 3 * steg / 10
                    iterationer = 1

                    If iterationer = 0 Then iterationer = 1

                    knutvärde = knutflytt.Value(Bar.StartNode, cas_num)
                    knutvärde2 = knutflytt.Value(Bar.EndNode, cas_num)
                    RNode = NodeServer.Get(Bar.StartNode)
                    RNode2 = NodeServer.Get(Bar.EndNode)

                    For n = 1 To iterationer

                        value = deplace.Value(bar_num, (n - 1) / iterationer, cas_num)
                        value2 = deplace.Value(bar_num, n / iterationer, cas_num)

                        deflect1 = deflect.Value(bar_num, cas_num, (n - 1) / iterationer)
                        deflect2 = deflect.Value(bar_num, cas_num, n / iterationer)

                        dflect1(0) = deflect1.UX
                        dflect1(1) = deflect1.UY
                        dflect1(2) = deflect1.UZ
                        dflect2(0) = deflect2.UX
                        dflect2(1) = deflect2.UY
                        dflect2(2) = deflect2.UZ

                        startpoint(0) = knutvärde.UX * 10 + RNode.X + dflect1(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * (n - 1) / iterationer
                        startpoint(1) = knutvärde.UY * 10 + RNode.Y + dflect1(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * (n - 1) / iterationer
                        startpoint(2) = knutvärde.UZ * 10 + RNode.Z + dflect1(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * (n - 1) / iterationer
                        endpoint(0) = knutvärde.UX * 10 + RNode.X + dflect2(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * n / iterationer
                        endpoint(1) = knutvärde.UY * 10 + RNode.Y + dflect2(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * n / iterationer
                        endpoint(2) = knutvärde.UZ * 10 + RNode.Z + dflect2(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * n / iterationer

                        Dim myLine As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), New Point3d(endpoint(0) * 1000, endpoint(1) * 1000, endpoint(2) * 1000))
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)
                        Dim hej As IRobotBarStressData = fe_serv.Value(bar_num, cas_num, n / iterationer - 1 / iterationer * 0.5)
                        Dim värdet As Double = CInt(hej.Smax / 100000) / 10
                        Dim värdet2 As Double = Math.Abs(CInt(hej.Smin / 100000) / 10)

                        If värdet2 > värdet Then värdet = värdet2

                        If ddd > 0 Then
                            myLine.ColorIndex = 181 - CInt(värdet / ddd * 17) * 10
                        End If
                        myLine.LineWeight = 35

                        Dim avstånd As Double
                        avstånd = (Math.Abs(dflect1(0)) ^ 2 + Math.Abs(dflect1(1)) ^ 2 + Math.Abs(dflect1(2)) ^ 2) ^ 0.5
                        If maxnedböj < avstånd Then
                            maxnedböj = avstånd
                            maxnedböjx = New Point3d((startpoint(0) + endpoint(0)) * 500, (startpoint(1) + endpoint(1)) * 500, (startpoint(2) + endpoint(2)) * 500)
                        End If

                        avstånd = (Math.Abs(dflect2(0)) ^ 2 + Math.Abs(dflect2(1)) ^ 2 + Math.Abs(dflect2(2)) ^ 2) ^ 0.5
                        If maxnedböj < avstånd Then
                            maxnedböj = avstånd
                            maxnedböjx = New Point3d((startpoint(0) + endpoint(0)) * 500, (startpoint(1) + endpoint(1)) * 500, (startpoint(2) + endpoint(2)) * 500)
                        End If

                    Next

                    If Bar.HasLabel(I_LT_BAR_RELEASE) Then
                        RLabel = Bar.GetLabel(I_LT_BAR_RELEASE)
                        RelData = RLabel.Data

                        data1 = force_serv.Value(bar_num, cas_num, 0)
                        res_mx = data1.MX
                        res_my = data1.MY
                        res_mz = data1.MZ
                        If Math.Abs(res_mx) > knutmaxx And RelData.StartNode.RX <> 0 Then
                            knutmaxx = Math.Abs(res_mx)
                            knutmaxxx = RNode.X
                            knutmaxxy = RNode.Y
                            knutmaxxz = RNode.Z
                        End If
                        If Math.Abs(res_my) > knutmaxy And RelData.StartNode.RY <> 0 Then
                            knutmaxy = Math.Abs(res_my)
                            knutmaxyx = RNode.X
                            knutmaxyy = RNode.Y
                            knutmaxyz = RNode.Z
                        End If
                        If Math.Abs(res_mz) > knutmaxz And RelData.StartNode.RZ <> 0 Then
                            knutmaxz = Math.Abs(res_mz)
                            knutmaxzx = RNode.X
                            knutmaxzy = RNode.Y
                            knutmaxzz = RNode.Z
                        End If

                        data1 = force_serv.Value(bar_num, cas_num, 1)
                        res_mx = data1.MX
                        res_my = data1.MY
                        res_mz = data1.MZ
                        If Math.Abs(res_mx) > knutmaxx And RelData.EndNode.RX <> 0 Then
                            knutmaxx = Math.Abs(res_mx)
                            knutmaxxx = RNode2.X
                            knutmaxxy = RNode2.Y
                            knutmaxxz = RNode2.Z
                        End If
                        If Math.Abs(res_my) > knutmaxy And RelData.EndNode.RY <> 0 Then
                            knutmaxy = Math.Abs(res_my)
                            knutmaxyx = RNode2.X
                            knutmaxyy = RNode2.Y
                            knutmaxyz = RNode2.Z
                        End If
                        If Math.Abs(res_mz) > knutmaxz And RelData.EndNode.RZ <> 0 Then
                            knutmaxz = Math.Abs(res_mz)
                            knutmaxzx = RNode2.X
                            knutmaxzy = RNode2.Y
                            knutmaxzz = RNode2.Z
                        End If
                    End If
                Next

                ed.WriteMessage("läst in allt")

                Dim nod As IRobotNode
                Dim nod_col As IRobotCollection = robapp.Project.Structure.Nodes.GetAll()
                Dim cas_col As IRobotCaseCollection = robapp.Project.Structure.Cases.GetAll()
                Dim curUCSMatrix As Matrix3d = doc.Editor.CurrentUserCoordinateSystem
                Dim curUCS As CoordinateSystem3d = curUCSMatrix.CoordinateSystem3d

                For i = 1 To nod_col.Count
                    nod = nod_col.Get(i)
                    If nod.HasLabel(IRobotLabelType.I_LT_SUPPORT) Then

                        Dim mmax As Double = Nothing
                        Dim data2 As IRobotReactionData = serv.Value(nod.Number, cas_num)

                        Dim SupportData As RobotNodeSupportData
                        Dim supcode As String
                        SupportData = nod.GetLabel(IRobotLabelType.I_LT_SUPPORT).Data
                        supcode = ""
                        supcode = SupCheck(SupportData.UX) + SupCheck(SupportData.UY) + SupCheck(SupportData.UZ) + SupCheck(SupportData.RX) + SupCheck(SupportData.RY) + SupCheck(SupportData.RZ)

                        'MsgBox(supcode)

                        res_fx = data2.FX
                        res_fy = data2.FY
                        res_fz = data2.FZ
                        If Math.Abs(res_fx) > mmax Then mmax = Math.Abs(res_fx)
                        If Math.Abs(res_fz) > mmax Then mmax = Math.Abs(res_fz)
                        If Math.Abs(res_fy) > mmax Then mmax = Math.Abs(res_fy)
                        Dim acText As DBText = New DBText()
                        If res_fz < 0 Then

                            acText.Position = New Point3d(nod.X * 1000, nod.Y * 1000, nod.Z * 1000)
                            acText.Height = 50
                            acText.TextString = "Rmin:" & CInt(res_fz / 10) / 100 & "kN"
                            acText.ColorIndex = 10
                            acText.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText.Position))
                            btr.AppendEntity(acText)
                            tr.AddNewlyCreatedDBObject(acText, True)
                        Else

                            acText.Position = New Point3d(nod.X * 1000, nod.Y * 1000, nod.Z * 1000)
                            acText.Height = 50
                            acText.TextString = "Rmax:" & CInt(mmax / 10) / 100 & "kN"
                            acText.ColorIndex = 0
                            acText.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText.Position))
                            btr.AppendEntity(acText)
                            tr.AddNewlyCreatedDBObject(acText, True)

                        End If

                        cas_col = Nothing
                        nod = Nothing

                        Dim infoReader As System.IO.FileInfo
                        infoReader = My.Computer.FileSystem.GetFileInfo(robpath & supcode & ".dwg")
                        If infoReader.Exists Then
                            Dim acText2 As DBText = New DBText()
                            Dim blockRef As BlockReference = InsertFile(supcode, db, tr, robpath)
                            btr.AppendEntity(blockRef)
                            Dim acPt3d As Point3d = New Point3d(0, 0, 0)
                            Dim acVec3d As Vector3d = acPt3d.GetVectorTo(acText.Position)
                            blockRef.TransformBy(Matrix3d.Displacement(acVec3d))
                            tr.AddNewlyCreatedDBObject(blockRef, True)

                        End If
                    End If
                Next

                ed.WriteMessage("upplag")

                Dim model As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
                Dim ext As Extents3d = New Extents3d
                ext.AddBlockExtents(model)

                Dim p5 = New Point3d(ext.MinPoint.X - 1000, ext.MinPoint.Y, ext.MaxPoint.Z + 1000)
                Dim myLine13 As New Line(New Point3d(startpointstress(0) * 1000, startpointstress(1) * 1000, startpointstress(2) * 1000), p5)
                myLine13.ColorIndex = 10
                btr.AppendEntity(myLine13)
                tr.AddNewlyCreatedDBObject(myLine13, True)

                Dim acText3 As DBText = New DBText()
                acText3.Position = p5
                acText3.Height = 50
                acText3.TextString = "Max stress:" & CInt(ddd * 10) / 10 & "Mpa"
                acText3.ColorIndex = 10
                acText3.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText3.Position))
                btr.AppendEntity(acText3)
                tr.AddNewlyCreatedDBObject(acText3, True)

                startpoint(0) = knutmaxxx
                startpoint(1) = knutmaxxy
                startpoint(2) = knutmaxxz

                Dim p25 = New Point3d(ext.MinPoint.X - 1000, ext.MinPoint.Y, ext.MinPoint.Z - 1000)
                Dim myLine213 As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), p25)
                myLine213.ColorIndex = 50
                btr.AppendEntity(myLine213)
                tr.AddNewlyCreatedDBObject(myLine213, True)


                Dim acText7 As DBText = New DBText()
                acText7.Position = p25
                acText7.Height = 50
                acText7.ColorIndex = 2
                acText7.TextString = "MXmax:" & CInt(knutmaxx) & "Nm"
                acText7.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText7.Position))
                btr.AppendEntity(acText7)
                tr.AddNewlyCreatedDBObject(acText7, True)

                startpoint(0) = knutmaxyx
                startpoint(1) = knutmaxyy
                startpoint(2) = knutmaxyz
                Dim p15 = New Point3d(ext.MaxPoint.X + 1000, ext.MinPoint.Y, ext.MaxPoint.Z + 1000)
                Dim myLine33 As New Line(New Point3d(knutmaxyx * 1000, knutmaxyy * 1000, knutmaxyz * 1000), p15)
                myLine33.ColorIndex = 2
                btr.AppendEntity(myLine33)
                tr.AddNewlyCreatedDBObject(myLine33, True)

                Dim acText5 As DBText = New DBText()
                acText5.Position = p15
                acText5.Height = 50
                acText5.ColorIndex = 2
                acText5.TextString = "MYmax:" & CInt(knutmaxy) & "Nm"
                acText5.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText5.Position))
                btr.AppendEntity(acText5)
                tr.AddNewlyCreatedDBObject(acText5, True)

                startpoint(0) = knutmaxzx
                startpoint(1) = knutmaxzy
                startpoint(2) = knutmaxzz
                Dim p125 = New Point3d(ext.MaxPoint.X + 1000, ext.MaxPoint.Y, ext.MinPoint.Z - 1000)
                Dim myLine1213 As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), p125)
                myLine1213.ColorIndex = 5
                btr.AppendEntity(myLine1213)
                tr.AddNewlyCreatedDBObject(myLine1213, True)


                Dim acText6 As DBText = New DBText()
                acText6.Position = p125
                acText6.Height = 50
                acText6.TextString = "MZmax:" & CInt(knutmaxz) & "Nm"
                acText6.ColorIndex = 5
                acText6.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText6.Position))
                btr.AppendEntity(acText6)
                tr.AddNewlyCreatedDBObject(acText6, True)

                Dim p6 = New Point3d((ext.MinPoint.X + ext.MaxPoint.X) / 2 - Len("Maxdeform:" & CInt(maxnedböj * 1000) & "mm") * 20, (ext.MinPoint.Y + ext.MaxPoint.Y) / 2, ext.MaxPoint.Z + 1000)
                Dim myLine23 As New Line(New Point3d(maxnedböjx(0), maxnedböjx(1), maxnedböjx(2)), p6)
                myLine23.ColorIndex = 52
                btr.AppendEntity(myLine23)
                tr.AddNewlyCreatedDBObject(myLine23, True)

                Dim acText4 As DBText = New DBText()
                acText4.Position = p6
                acText4.Height = 50
                acText4.TextString = "Maxdeform:" & CInt(maxnedböj * 1000) & "mm"
                acText4.ColorIndex = 52
                acText4.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText4.Position))
                btr.AppendEntity(acText4)
                tr.AddNewlyCreatedDBObject(acText4, True)

                ed.WriteMessage("maxvärden")

                For plot = 1 To 0 Step -1 / 20

                    startpoint(0) = ext.MinPoint.X - 450
                    'startpoint(1) = ext.MinPoint.Y + (plot - 0.05) * 1500 - 1200
                    'startpoint(2) = ext.MinPoint.Z
                    startpoint(1) = ext.MinPoint.Y
                    startpoint(2) = ext.MinPoint.Z + (plot - 0.05) * 1500


                    endpoint(0) = ext.MinPoint.X - 450
                    'endpoint(1) = ext.MinPoint.Y + plot * 1500 - 1200
                    'endpoint(2) = ext.MinPoint.Z
                    endpoint(1) = ext.MinPoint.Y
                    endpoint(2) = ext.MinPoint.Z + plot * 1500

                    Dim myLine As New Line(New Point3d(startpoint(0), startpoint(1), startpoint(2)), New Point3d(endpoint(0), endpoint(1), endpoint(2)))
                    myLine.ColorIndex = 210 - CInt(plot * 20) * 10
                    myLine.LineWeight = 35
                    btr.AppendEntity(myLine)
                    tr.AddNewlyCreatedDBObject(myLine, True)

                    endpoint(2) = ext.MinPoint.Z + plot * 1500 - 75

                    Dim acText2 As DBText = New DBText()
                    acText2.Position = New Point3d(endpoint(0), endpoint(1), endpoint(2))
                    acText2.Height = 50
                    acText2.TextString = " " & CInt(ddd * plot) & "MPa"
                    acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                    btr.AppendEntity(acText2)
                    tr.AddNewlyCreatedDBObject(acText2, True)

                Next

                ed.WriteMessage("graf")

                Dim LoadMngr As IRobotLoadRecordMngr
                Dim Przyp As RobotSimpleCase
                Przyp = robapp.Project.Structure.Cases.Get(4)
                LoadMngr = Przyp.Records
                Dim node As RobotNode = Nothing

                For laster As Double = 1 To LoadMngr.Count
                    Dim Load As IRobotLoadRecord = Nothing
                    Load = LoadMngr.Get(laster)

                    If Load.Type.ToString = "I_LRT_NODE_FORCE" Then

                        Dim lastx As Double = Load.GetValue(0)
                        Dim lasty As Double = Load.GetValue(1)
                        Dim last As Double = -Load.GetValue(2)
                        Dim avstånd As Double = (Math.Abs(lastx) ^ 2 + Math.Abs(lasty) ^ 2 + Math.Abs(last) ^ 2) ^ 0.5

                        'Dim knut As Integer = Load.Objects.Get(laster)
                        Dim knut As Integer = Load.Objects.Get(1)
                        'MsgBox(knut)


                        node = NodeServer.Get(knut)

                        Dim p1 As New Point3d(node.X * 1000, node.Y * 1000, node.Z * 1000)
                        Dim p2 As New Point3d(node.X * 1000 - Load.GetValue(0) / 10, node.Y * 1000 - Load.GetValue(1) / 10, node.Z * 1000 - Load.GetValue(2) / 10)

                        Dim myLine As New Line(p1, p2)
                        myLine.ColorIndex = 1
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)

                        Dim p4 = New Point3d(p1.X - last / 100, p1.Y, p1.Z + last / 100)
                        Dim myLine3 As New Line(p1, p4)
                        myLine3.ColorIndex = 1
                        btr.AppendEntity(myLine3)
                        tr.AddNewlyCreatedDBObject(myLine3, True)

                        p4 = New Point3d(p1.X + last / 100, p1.Y, p1.Z + last / 100)
                        Dim myLine4 As New Line(p1, p4)
                        myLine4.ColorIndex = 1
                        btr.AppendEntity(myLine4)
                        tr.AddNewlyCreatedDBObject(myLine4, True)


                        Dim acText2 As DBText = New DBText()
                        acText2.Position = New Point3d(p2(0) - Len("F=" & CInt(avstånd / 10) / 100 & "kN") * 20, p2(1), p2(2))
                        acText2.Height = 50
                        acText2.TextString = "F=" & CInt(avstånd / 10) / 100 & "kN"
                        acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                        acText2.ColorIndex = 1
                        btr.AppendEntity(acText2)
                        tr.AddNewlyCreatedDBObject(acText2, True)


                    End If
                Next

                ed.WriteMessage("punktlaster")

                Dim I_OT_PANEL As Integer = 4
                Dim I_GOT_CONTOUR As Integer = 2
                Dim RSelection As RobotSelection
                RSelection = robapp.Project.Structure.Selections.Get(I_OT_PANEL)
                Dim PanelCol As RobotObjObjectCollection
                PanelCol = robapp.Project.Structure.Objects.GetMany(RSelection)

                GoTo hoppautbred

                Przyp = robapp.Project.Structure.Cases.Get(3)
                LoadMngr = Przyp.Records
                For laster As Double = 1 To LoadMngr.Count
                    Dim Load As IRobotLoadRecord = Nothing
                    Load = LoadMngr.Get(laster)

                    If Load.Type.ToString = "I_LRT_UNIFORM" Then
                        Dim last As Double = -Load.GetValue(2)
                        Dim på As Integer = Load.Objects.Get(1)

                        Dim Obj As RobotObjObject
                        Dim ContourGeometry As RobotGeoContour
                        Dim Segments As RobotGeoSegmentCollection
                        Dim Segment As RobotGeoSegment

                        'Obj = robapp.Project.Structure.Objects.Get(PanelCol.Get(på).Number)
                        Obj = robapp.Project.Structure.Objects.Get(på)

                        If Obj.Main.GetGeometry.Type = I_GOT_CONTOUR Then

                            ContourGeometry = Obj.Main.GetGeometry
                            Segments = ContourGeometry.Segments

                            Dim acPolyMesh As PolygonMesh = New PolygonMesh
                            acPolyMesh.MSize = 2
                            acPolyMesh.NSize = 4
                            acPolyMesh.MakeNClosed()
                            'What is N???
                            'acPolyMesh.MakeMClosed();
                            'What is M???
                            ' Add the new object to the block table record and the transaction
                            acPolyMesh.ColorIndex = 1
                            btr.AppendEntity(acPolyMesh)
                            tr.AddNewlyCreatedDBObject(acPolyMesh, True)
                            'Creating collection of points to add to the mesh
                            Dim acPts3dPMesh As Point3dCollection = New Point3dCollection
                            For i = 1 To Segments.Count
                                Segment = Segments.Get(i)
                                acPts3dPMesh.Add(New Point3d(Segment.P1.X * 1000, Segment.P1.Y * 1000, Segment.P1.Z * 1000))
                            Next i
                            For i = 1 To Segments.Count
                                Segment = Segments.Get(i)
                                acPts3dPMesh.Add(New Point3d(Segment.P1.X * 1000, Segment.P1.Y * 1000, Segment.P1.Z * 1000 + 100 + last / 10))
                            Next i

                            'Converting those points to PolygonMeshVertecies and appending them to the PolygonMesh
                            For Each acPt3d As Point3d In acPts3dPMesh
                                Dim acPMeshVer As PolygonMeshVertex = New PolygonMeshVertex(acPt3d)
                                acPolyMesh.AppendVertex(acPMeshVer)
                                tr.AddNewlyCreatedDBObject(acPMeshVer, True)
                            Next

                            Dim acText2 As DBText = New DBText()
                            acText2.Position = New Point3d((acPolyMesh.GeometricExtents.MaxPoint.X - Len("F=" & last / 1000 & "kN/m²") * 20 + acPolyMesh.GeometricExtents.MinPoint.X) / 2, (acPolyMesh.GeometricExtents.MaxPoint.Y + acPolyMesh.GeometricExtents.MinPoint.Y) / 2, acPolyMesh.GeometricExtents.MaxPoint.Z + 20)
                            acText2.Height = 50

                            acText2.TextString = "Q=" & last / 1000 & "kN/m²"
                            acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                            acText2.ColorIndex = 1
                            btr.AppendEntity(acText2)
                            tr.AddNewlyCreatedDBObject(acText2, True)

                        End If

                    End If
                    'ed.WriteMessage(vbLf & Load.Type.ToString)


                    If Load.Type.ToString = "I_LRT_BAR_UNIFORM" Then
                        Dim last As Double = -Load.GetValue(2)
                        Dim iknut As Integer = Load.Objects.Get(1)

                        Bar = robapp.Project.Structure.Bars.Get(iknut)
                        Dim bar_num As Integer = Bar.Number

                        node = NodeServer.Get(Bar.StartNode)
                        RNode2 = NodeServer.Get(Bar.EndNode)

                        Dim p1 As New Point3d(node.X * 1000, node.Y * 1000, node.Z * 1000)
                        Dim p2 As New Point3d(RNode2.X * 1000, RNode2.Y * 1000, RNode2.Z * 1000)

                        Dim myLine As New Line(p1, p2)
                        myLine.ColorIndex = 1
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)

                        For i As Integer = 0 To myLine.Length Step 100

                            'Dim p3 As Point3d = New Point3d(p1.X + (p2.X - p1.X) / 10 * i, p1.Y + (p2.Y - p1.Y) / 10 * i, p1.Z + (p2.Z - p1.Z) / 10 * i)
                            Dim p3 As Point3d = New Point3d(p1.X + (p2.X - p1.X) / myLine.Length * i, p1.Y + (p2.Y - p1.Y) / myLine.Length * i, p1.Z + (p2.Z - p1.Z) / myLine.Length * i)
                            Dim p4 As Point3d = New Point3d(p3.X, p3.Y, p3.Z + 100 + last / 100)
                            Dim myLine2 As New Line(p3, p4)
                            myLine2.ColorIndex = 1
                            btr.AppendEntity(myLine2)
                            tr.AddNewlyCreatedDBObject(myLine2, True)

                            p4 = New Point3d(p3.X + 10 + last / 1000, p3.Y, p3.Z + 10 + last / 1000)
                            Dim myLine3 As New Line(p3, p4)
                            myLine3.ColorIndex = 1
                            btr.AppendEntity(myLine3)
                            tr.AddNewlyCreatedDBObject(myLine3, True)

                            p4 = New Point3d(p3.X - 10 - last / 1000, p3.Y, p3.Z + 10 + last / 1000)
                            Dim myLine4 As New Line(p3, p4)
                            myLine4.ColorIndex = 1
                            btr.AppendEntity(myLine4)
                            tr.AddNewlyCreatedDBObject(myLine4, True)

                        Next

                        Dim acText2 As DBText = New DBText()
                        Dim textpunkt As Point3d = New Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2 + 110 + last / 100)
                        startpoint(0) = textpunkt.X
                        startpoint(1) = textpunkt.Y
                        startpoint(2) = textpunkt.Z
                        endpoint = PolarPoint(startpoint, myLine.Angle, -Len(last & "N/m") * 40 / 2)
                        acText2.Position = New Point3d(endpoint(0), endpoint(1), endpoint(2))
                        acText2.Height = 50
                        acText2.TextString = last & "N/m"
                        acText2.ColorIndex = 1
                        acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                        btr.AppendEntity(acText2)
                        tr.AddNewlyCreatedDBObject(acText2, True)


                    End If
                    'If Load.Type.ToString = "I_LRT_BAR_TRAPEZOIDALE" Then
                Next
hoppautbred:

                nod_col = Nothing
                serv = Nothing
                tr.Commit()
                robapp.Interactive = True
                robapp = Nothing
            End Using
        End Using
        Me.Close()

    End Sub

 

Tags (3)
5 REPLIES 5
Message 1 of 6
jokiller70
in reply to: jokiller70

I have been using the attached code for many years, but with Robot 2021 it is extreamly slow.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Show()

        'On Error Resume Next

        Dim screenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim screenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Me.Left = screenWidth / 2
        Me.Top = screenHeight / 2


        Dim KnlL As RobotNonlinearLink = Nothing
        Dim nlLP As RobotOM.IRobotNonlinearLinkParams = Nothing
        Dim nlL As RobotOM.RobotNonlinearLink = Nothing
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim db As Database = doc.Database

        Dim I_CT_EXTREME_PARAMS As Integer = 42
        Dim I_EVT_STRESS_BAR_SMAX As Integer = 171
        Dim I_OT_BAR As Integer = 1
        Dim I_OT_CASE As Integer = 2

        Dim knutmaxxx As Double
        Dim knutmaxxy As Double
        Dim knutmaxxz As Double
        Dim knutmaxyx As Double
        Dim knutmaxyy As Double
        Dim knutmaxyz As Double
        Dim knutmaxzx As Double
        Dim knutmaxzy As Double
        Dim knutmaxzz As Double

        Dim knutmaxx As Double
        'Dim knutmaxxnod As Integer
        'Dim knutmaxxstart As Integer
        Dim knutmaxy As Double
        'Dim knutmaxynod As Integer
        'Dim knutmaxystart As Integer
        Dim knutmaxz As Double
        Dim robapp As IRobotApplication = Nothing
        robapp = New RobotApplication

        Using dl As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()

            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim btr As BlockTableRecord = TryCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
                Dim startpoint(0 To 2) As Double
                Dim startpointstress(0 To 2) As Double
                Dim endpoint(0 To 2) As Double

                Dim psto As New PromptStringOptions(vbLf & "filnamn att läsa in: ")
                psto.AllowSpaces = True
                psto.DefaultValue = "c:\calc.rtd"
                Dim stres As PromptResult
                stres = ed.GetString(psto)
                If stres.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim s2dpath As String = stres.StringResult

                Dim psto2 As New PromptStringOptions(vbLf & "path to Robot blocks: ")
                psto2.AllowSpaces = True
                psto2.DefaultValue = "C:\Dropbox (MonZon Group)\Utveckling med Berth\robot blocks\"  'old block
                Dim stres2 As PromptResult
                stres2 = ed.GetString(psto2)
                If stres2.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim robpath As String = stres2.StringResult

                Dim psto3 As New PromptStringOptions(vbLf & "iterationssteg")
                psto3.AllowSpaces = True
                psto3.DefaultValue = "10"  'old block
                Dim stres3 As PromptResult
                stres3 = ed.GetString(psto3)
                If stres3.Status <> PromptStatus.OK Then
                    Return
                End If
                Dim steg As Integer = stres3.StringResult
                Dim tm As Transaction =
                            db.TransactionManager.StartTransaction()
                Using tm
                    Dim st As TextStyleTable = CType(tm.GetObject(
                                db.TextStyleTableId,
                                OpenMode.ForWrite, False),
                                                 TextStyleTable)
                    Dim str As TextStyleTableRecord =
                                        New TextStyleTableRecord()
                    str.Name = "MyStyle"
                    st.Add(str)

                    'Following are properties to set by default,
                    'you can also modify them

                    'str.FileName = "txt.shx"
                    'str.PriorSize = 0.2               
                    'str.ObliquingAngle = 0.0
                    'str.XScale = 1.0
                    'str.TextSize = 0.0
                    'str.IsVertical = False
                    'str.IsShapeFile = False

                    'using the font descriptor to set the new font style
                    'Imports Autodesk.AutoCAD.GraphicsInterface
                    str.FileName = "STANDARD.shx"
                    tm.AddNewlyCreatedDBObject(str, True)

                    'make as current
                    db.Textstyle = str.ObjectId
                    tm.Commit()
                End Using

                If robapp.Project.IsActive = True Then
                Else
                    robapp.Project.Open(s2dpath)
                End If
                'MsgBox("inget öppet i Robot?")
                'Me.Close()
                'Exit Sub

                robapp.Visible = True

                'Dim force_serv As IRobotBarForceServer = robapp.Project.Structure.Results.Bars.Forces
                Dim fe_serv As IRobotBarStressServer = robapp.Project.Structure.Results.Bars.Stresses
                Dim REV As RobotExtremeValue
                Dim Params As RobotExtremeParams
                Params = New RobotExtremeParams
                Params = robapp.CmpntFactory.Create(I_CT_EXTREME_PARAMS)
                Params.BarDivision = 30
                Dim rs As RobotSelection
                rs = robapp.Project.Structure.Selections.CreateFull(I_OT_BAR)
                Dim rsc As RobotSelection
                rsc = robapp.Project.Structure.Selections.CreateFull(I_OT_CASE)

                Dim casecol As RobotCaseCollection = robapp.Project.Structure.Cases.GetAll

                Dim j As Integer = 1
                Do While (j <= casecol.Count)
                    Dim rc As IRobotCase = casecol.Get(j)
                    Dim AT As IRobotCaseAnalizeType = rc.AnalizeType
                    If AT = IRobotCaseAnalizeType.I_CAT_STATIC_NONLINEAR Then
                    Else
                        If robapp.Project.Structure.Cases.Exist(j) = True Then
                            robapp.Project.Structure.Cases.SetAuxiliary(j, True)
                        End If
                    End If
                    j = (j + 1)
                Loop

                Params.Selection.Set(I_OT_BAR, rs)
                Params.Selection.Set(I_OT_CASE, rsc)
                Params.ValueType = I_EVT_STRESS_BAR_SMAX

                REV = robapp.Project.Structure.Results.Extremes.MaxValue(Params)
                Dim stresstemp As Double = Math.Abs(CInt(REV.Value / 100000) / 10)
                Label2.Text = Math.Abs(CInt(REV.Value / 100000) / 10)

                Params.ValueType = IRobotExtremeValueType.I_EVT_STRESS_BAR_SMIN
                REV = robapp.Project.Structure.Results.Extremes.MinValue(Params)
                Label3.Text = Math.Abs(CInt(REV.Value / 100000) / 10)

                If stresstemp > Math.Abs(CInt(REV.Value / 100000) / 10) Then
                    Params.ValueType = I_EVT_STRESS_BAR_SMAX
                    REV = robapp.Project.Structure.Results.Extremes.MaxValue(Params)
                End If

                Dim ddd As Double = Math.Abs(CInt(REV.Value / 100000) / 10)
                Dim cas_num As Integer = REV.Case
                Dim var As Double = REV.Position
                Dim vilkenbar As Integer = REV.Bar

                Dim res_fx As Double, res_fz As Double, res_fy As Double, res_mx As Double, res_my As Double, res_mz As Double

                Dim serv As IRobotReactionServer = robapp.Project.Structure.Results.Nodes.Reactions
                Dim knutflytt As RobotNodeDisplacementServer = robapp.Project.Structure.Results.Nodes.Displacements
                Dim NodeServer As RobotNodeServer = robapp.Project.Structure.Nodes
                Dim bar_col As IRobotCollection = robapp.Project.Structure.Bars.GetAll()
                Dim value As RobotOM.IRobotDisplacementData
                Dim value2 As RobotOM.IRobotDisplacementData
                Dim deflect As RobotBarDeflectionServer = Nothing
                Dim deflect1 As RobotBarDeflectionData
                Dim deflect2 As RobotBarDeflectionData
                Dim deplace As RobotBarDisplacementServer = Nothing
                deflect = robapp.Project.Structure.Results.Bars.Deflections
                deplace = robapp.Project.Structure.Results.Bars.Displacements

                Dim force_serv As IRobotBarForceServer
                Dim data1 As IRobotBarForceData
                force_serv = robapp.Project.Structure.Results.Bars.Forces

                Dim dflect1(0 To 2) As Double
                Dim dflect2(0 To 2) As Double
                Dim mtx(3, 3) As Double
                Dim maxnedböj As Double
                'Dim maxsstress As Double
                Dim maxnedböjx As Autodesk.AutoCAD.Geometry.Point3d
0:
                Dim maxmy As Double = 0
                Dim mymaxvar(0 To 2) As Double

                Dim RLabel As RobotLabel
                Dim RelData As RobotBarReleaseData
                Dim I_LT_BAR_RELEASE As Integer = 4
                'If robapp.Project.Structure.Bars.FreeNumber = 0 Then
                'MsgBox("Inget öppet i Robot?")
                'End Sub
                'End If
                If bar_col.Count = 0 Then
                    MsgBox("Inget öppet i Robot?")
                    Me.Close()
                    Exit Sub
                End If
                'If vilkenbar = 0 Then
                'MsgBox("Inget beräkning?")
                'robapp.Visible = True
                'Me.Close()
                'Exit Sub
                'End If

                Dim Bar As RobotBar = robapp.Project.Structure.Bars.Get(vilkenbar)
                Dim RNode As RobotNode = NodeServer.Get(Bar.StartNode)
                Dim RNode2 As RobotNode = NodeServer.Get(Bar.EndNode)
                Dim knutvärde As RobotOM.IRobotDisplacementData = knutflytt.Value(Bar.StartNode, cas_num)
                Dim knutvärde2 As RobotOM.IRobotDisplacementData = knutflytt.Value(Bar.EndNode, cas_num)
                deflect1 = deflect.Value(vilkenbar, cas_num, var)

                'startpointstress(0) = knutvärde.UX * 10 + RNode.X + dflect2(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * var
                'startpointstress(1) = knutvärde.UY * 10 + RNode.Y + dflect2(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * var
                'startpointstress(2) = knutvärde.UZ * 10 + RNode.Z + dflect2(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * var

                startpointstress(0) = RNode.X + knutvärde.UX * 10 + (RNode2.X - RNode.X) * var + knutvärde.UX * 10 + (knutvärde2.UX * 10 - knutvärde.UX * 10) * var + deflect1.UX * 10
                startpointstress(1) = RNode.Y + knutvärde.UY * 10 + (RNode2.Y - RNode.Y) * var + knutvärde.UY * 10 + (knutvärde2.UY * 10 - knutvärde.UY * 10) * var + deflect1.UY * 10
                startpointstress(2) = RNode.Z + knutvärde.UZ * 10 + (RNode2.Z - RNode.Z) * var + knutvärde.UZ * 10 + (knutvärde2.UZ * 10 - knutvärde.UZ * 10) * var + deflect1.UZ * 10

                For i As Integer = 1 To bar_col.Count
                    'System.Windows.Forms.Application.DoEvents()

                    Me.Label1.Text = i & " av:" & bar_col.Count
                    Me.Text = i & ":" & bar_col.Count
                    Bar = bar_col.Get(i)
                    Dim bar_num As Long = Bar.Number
                    Dim iterationer As Integer = Bar.Length / 0.3 * 3 * steg / 10
                    iterationer = 1

                    If iterationer = 0 Then iterationer = 1

                    knutvärde = knutflytt.Value(Bar.StartNode, cas_num)
                    knutvärde2 = knutflytt.Value(Bar.EndNode, cas_num)
                    RNode = NodeServer.Get(Bar.StartNode)
                    RNode2 = NodeServer.Get(Bar.EndNode)

                    For n = 1 To iterationer

                        value = deplace.Value(bar_num, (n - 1) / iterationer, cas_num)
                        value2 = deplace.Value(bar_num, n / iterationer, cas_num)

                        deflect1 = deflect.Value(bar_num, cas_num, (n - 1) / iterationer)
                        deflect2 = deflect.Value(bar_num, cas_num, n / iterationer)

                        dflect1(0) = deflect1.UX
                        dflect1(1) = deflect1.UY
                        dflect1(2) = deflect1.UZ
                        dflect2(0) = deflect2.UX
                        dflect2(1) = deflect2.UY
                        dflect2(2) = deflect2.UZ

                        startpoint(0) = knutvärde.UX * 10 + RNode.X + dflect1(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * (n - 1) / iterationer
                        startpoint(1) = knutvärde.UY * 10 + RNode.Y + dflect1(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * (n - 1) / iterationer
                        startpoint(2) = knutvärde.UZ * 10 + RNode.Z + dflect1(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * (n - 1) / iterationer
                        endpoint(0) = knutvärde.UX * 10 + RNode.X + dflect2(0) * 10 + (RNode2.X + knutvärde2.UX * 10 - (RNode.X + knutvärde.UX * 10)) * n / iterationer
                        endpoint(1) = knutvärde.UY * 10 + RNode.Y + dflect2(1) * 10 + (RNode2.Y + knutvärde2.UY * 10 - (RNode.Y + knutvärde.UY * 10)) * n / iterationer
                        endpoint(2) = knutvärde.UZ * 10 + RNode.Z + dflect2(2) * 10 + (RNode2.Z + knutvärde2.UZ * 10 - (RNode.Z + knutvärde.UZ * 10)) * n / iterationer

                        Dim myLine As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), New Point3d(endpoint(0) * 1000, endpoint(1) * 1000, endpoint(2) * 1000))
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)
                        Dim hej As IRobotBarStressData = fe_serv.Value(bar_num, cas_num, n / iterationer - 1 / iterationer * 0.5)
                        Dim värdet As Double = CInt(hej.Smax / 100000) / 10
                        Dim värdet2 As Double = Math.Abs(CInt(hej.Smin / 100000) / 10)

                        If värdet2 > värdet Then värdet = värdet2

                        If ddd > 0 Then
                            myLine.ColorIndex = 181 - CInt(värdet / ddd * 17) * 10
                        End If
                        myLine.LineWeight = 35

                        Dim avstånd As Double
                        avstånd = (Math.Abs(dflect1(0)) ^ 2 + Math.Abs(dflect1(1)) ^ 2 + Math.Abs(dflect1(2)) ^ 2) ^ 0.5
                        If maxnedböj < avstånd Then
                            maxnedböj = avstånd
                            maxnedböjx = New Point3d((startpoint(0) + endpoint(0)) * 500, (startpoint(1) + endpoint(1)) * 500, (startpoint(2) + endpoint(2)) * 500)
                        End If

                        avstånd = (Math.Abs(dflect2(0)) ^ 2 + Math.Abs(dflect2(1)) ^ 2 + Math.Abs(dflect2(2)) ^ 2) ^ 0.5
                        If maxnedböj < avstånd Then
                            maxnedböj = avstånd
                            maxnedböjx = New Point3d((startpoint(0) + endpoint(0)) * 500, (startpoint(1) + endpoint(1)) * 500, (startpoint(2) + endpoint(2)) * 500)
                        End If

                    Next

                    If Bar.HasLabel(I_LT_BAR_RELEASE) Then
                        RLabel = Bar.GetLabel(I_LT_BAR_RELEASE)
                        RelData = RLabel.Data

                        data1 = force_serv.Value(bar_num, cas_num, 0)
                        res_mx = data1.MX
                        res_my = data1.MY
                        res_mz = data1.MZ
                        If Math.Abs(res_mx) > knutmaxx And RelData.StartNode.RX <> 0 Then
                            knutmaxx = Math.Abs(res_mx)
                            knutmaxxx = RNode.X
                            knutmaxxy = RNode.Y
                            knutmaxxz = RNode.Z
                        End If
                        If Math.Abs(res_my) > knutmaxy And RelData.StartNode.RY <> 0 Then
                            knutmaxy = Math.Abs(res_my)
                            knutmaxyx = RNode.X
                            knutmaxyy = RNode.Y
                            knutmaxyz = RNode.Z
                        End If
                        If Math.Abs(res_mz) > knutmaxz And RelData.StartNode.RZ <> 0 Then
                            knutmaxz = Math.Abs(res_mz)
                            knutmaxzx = RNode.X
                            knutmaxzy = RNode.Y
                            knutmaxzz = RNode.Z
                        End If

                        data1 = force_serv.Value(bar_num, cas_num, 1)
                        res_mx = data1.MX
                        res_my = data1.MY
                        res_mz = data1.MZ
                        If Math.Abs(res_mx) > knutmaxx And RelData.EndNode.RX <> 0 Then
                            knutmaxx = Math.Abs(res_mx)
                            knutmaxxx = RNode2.X
                            knutmaxxy = RNode2.Y
                            knutmaxxz = RNode2.Z
                        End If
                        If Math.Abs(res_my) > knutmaxy And RelData.EndNode.RY <> 0 Then
                            knutmaxy = Math.Abs(res_my)
                            knutmaxyx = RNode2.X
                            knutmaxyy = RNode2.Y
                            knutmaxyz = RNode2.Z
                        End If
                        If Math.Abs(res_mz) > knutmaxz And RelData.EndNode.RZ <> 0 Then
                            knutmaxz = Math.Abs(res_mz)
                            knutmaxzx = RNode2.X
                            knutmaxzy = RNode2.Y
                            knutmaxzz = RNode2.Z
                        End If
                    End If
                Next

                ed.WriteMessage("läst in allt")

                Dim nod As IRobotNode
                Dim nod_col As IRobotCollection = robapp.Project.Structure.Nodes.GetAll()
                Dim cas_col As IRobotCaseCollection = robapp.Project.Structure.Cases.GetAll()
                Dim curUCSMatrix As Matrix3d = doc.Editor.CurrentUserCoordinateSystem
                Dim curUCS As CoordinateSystem3d = curUCSMatrix.CoordinateSystem3d

                For i = 1 To nod_col.Count
                    nod = nod_col.Get(i)
                    If nod.HasLabel(IRobotLabelType.I_LT_SUPPORT) Then

                        Dim mmax As Double = Nothing
                        Dim data2 As IRobotReactionData = serv.Value(nod.Number, cas_num)

                        Dim SupportData As RobotNodeSupportData
                        Dim supcode As String
                        SupportData = nod.GetLabel(IRobotLabelType.I_LT_SUPPORT).Data
                        supcode = ""
                        supcode = SupCheck(SupportData.UX) + SupCheck(SupportData.UY) + SupCheck(SupportData.UZ) + SupCheck(SupportData.RX) + SupCheck(SupportData.RY) + SupCheck(SupportData.RZ)

                        'MsgBox(supcode)

                        res_fx = data2.FX
                        res_fy = data2.FY
                        res_fz = data2.FZ
                        If Math.Abs(res_fx) > mmax Then mmax = Math.Abs(res_fx)
                        If Math.Abs(res_fz) > mmax Then mmax = Math.Abs(res_fz)
                        If Math.Abs(res_fy) > mmax Then mmax = Math.Abs(res_fy)
                        Dim acText As DBText = New DBText()
                        If res_fz < 0 Then

                            acText.Position = New Point3d(nod.X * 1000, nod.Y * 1000, nod.Z * 1000)
                            acText.Height = 50
                            acText.TextString = "Rmin:" & CInt(res_fz / 10) / 100 & "kN"
                            acText.ColorIndex = 10
                            acText.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText.Position))
                            btr.AppendEntity(acText)
                            tr.AddNewlyCreatedDBObject(acText, True)
                        Else

                            acText.Position = New Point3d(nod.X * 1000, nod.Y * 1000, nod.Z * 1000)
                            acText.Height = 50
                            acText.TextString = "Rmax:" & CInt(mmax / 10) / 100 & "kN"
                            acText.ColorIndex = 0
                            acText.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText.Position))
                            btr.AppendEntity(acText)
                            tr.AddNewlyCreatedDBObject(acText, True)

                        End If

                        cas_col = Nothing
                        nod = Nothing

                        Dim infoReader As System.IO.FileInfo
                        infoReader = My.Computer.FileSystem.GetFileInfo(robpath & supcode & ".dwg")
                        If infoReader.Exists Then
                            Dim acText2 As DBText = New DBText()
                            Dim blockRef As BlockReference = InsertFile(supcode, db, tr, robpath)
                            btr.AppendEntity(blockRef)
                            Dim acPt3d As Point3d = New Point3d(0, 0, 0)
                            Dim acVec3d As Vector3d = acPt3d.GetVectorTo(acText.Position)
                            blockRef.TransformBy(Matrix3d.Displacement(acVec3d))
                            tr.AddNewlyCreatedDBObject(blockRef, True)

                        End If
                    End If
                Next

                ed.WriteMessage("upplag")

                Dim model As BlockTableRecord = CType(tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite), BlockTableRecord)
                Dim ext As Extents3d = New Extents3d
                ext.AddBlockExtents(model)

                Dim p5 = New Point3d(ext.MinPoint.X - 1000, ext.MinPoint.Y, ext.MaxPoint.Z + 1000)
                Dim myLine13 As New Line(New Point3d(startpointstress(0) * 1000, startpointstress(1) * 1000, startpointstress(2) * 1000), p5)
                myLine13.ColorIndex = 10
                btr.AppendEntity(myLine13)
                tr.AddNewlyCreatedDBObject(myLine13, True)

                Dim acText3 As DBText = New DBText()
                acText3.Position = p5
                acText3.Height = 50
                acText3.TextString = "Max stress:" & CInt(ddd * 10) / 10 & "Mpa"
                acText3.ColorIndex = 10
                acText3.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText3.Position))
                btr.AppendEntity(acText3)
                tr.AddNewlyCreatedDBObject(acText3, True)

                startpoint(0) = knutmaxxx
                startpoint(1) = knutmaxxy
                startpoint(2) = knutmaxxz

                Dim p25 = New Point3d(ext.MinPoint.X - 1000, ext.MinPoint.Y, ext.MinPoint.Z - 1000)
                Dim myLine213 As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), p25)
                myLine213.ColorIndex = 50
                btr.AppendEntity(myLine213)
                tr.AddNewlyCreatedDBObject(myLine213, True)


                Dim acText7 As DBText = New DBText()
                acText7.Position = p25
                acText7.Height = 50
                acText7.ColorIndex = 2
                acText7.TextString = "MXmax:" & CInt(knutmaxx) & "Nm"
                acText7.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText7.Position))
                btr.AppendEntity(acText7)
                tr.AddNewlyCreatedDBObject(acText7, True)

                startpoint(0) = knutmaxyx
                startpoint(1) = knutmaxyy
                startpoint(2) = knutmaxyz
                Dim p15 = New Point3d(ext.MaxPoint.X + 1000, ext.MinPoint.Y, ext.MaxPoint.Z + 1000)
                Dim myLine33 As New Line(New Point3d(knutmaxyx * 1000, knutmaxyy * 1000, knutmaxyz * 1000), p15)
                myLine33.ColorIndex = 2
                btr.AppendEntity(myLine33)
                tr.AddNewlyCreatedDBObject(myLine33, True)

                Dim acText5 As DBText = New DBText()
                acText5.Position = p15
                acText5.Height = 50
                acText5.ColorIndex = 2
                acText5.TextString = "MYmax:" & CInt(knutmaxy) & "Nm"
                acText5.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText5.Position))
                btr.AppendEntity(acText5)
                tr.AddNewlyCreatedDBObject(acText5, True)

                startpoint(0) = knutmaxzx
                startpoint(1) = knutmaxzy
                startpoint(2) = knutmaxzz
                Dim p125 = New Point3d(ext.MaxPoint.X + 1000, ext.MaxPoint.Y, ext.MinPoint.Z - 1000)
                Dim myLine1213 As New Line(New Point3d(startpoint(0) * 1000, startpoint(1) * 1000, startpoint(2) * 1000), p125)
                myLine1213.ColorIndex = 5
                btr.AppendEntity(myLine1213)
                tr.AddNewlyCreatedDBObject(myLine1213, True)


                Dim acText6 As DBText = New DBText()
                acText6.Position = p125
                acText6.Height = 50
                acText6.TextString = "MZmax:" & CInt(knutmaxz) & "Nm"
                acText6.ColorIndex = 5
                acText6.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText6.Position))
                btr.AppendEntity(acText6)
                tr.AddNewlyCreatedDBObject(acText6, True)

                Dim p6 = New Point3d((ext.MinPoint.X + ext.MaxPoint.X) / 2 - Len("Maxdeform:" & CInt(maxnedböj * 1000) & "mm") * 20, (ext.MinPoint.Y + ext.MaxPoint.Y) / 2, ext.MaxPoint.Z + 1000)
                Dim myLine23 As New Line(New Point3d(maxnedböjx(0), maxnedböjx(1), maxnedböjx(2)), p6)
                myLine23.ColorIndex = 52
                btr.AppendEntity(myLine23)
                tr.AddNewlyCreatedDBObject(myLine23, True)

                Dim acText4 As DBText = New DBText()
                acText4.Position = p6
                acText4.Height = 50
                acText4.TextString = "Maxdeform:" & CInt(maxnedböj * 1000) & "mm"
                acText4.ColorIndex = 52
                acText4.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText4.Position))
                btr.AppendEntity(acText4)
                tr.AddNewlyCreatedDBObject(acText4, True)

                ed.WriteMessage("maxvärden")

                For plot = 1 To 0 Step -1 / 20

                    startpoint(0) = ext.MinPoint.X - 450
                    'startpoint(1) = ext.MinPoint.Y + (plot - 0.05) * 1500 - 1200
                    'startpoint(2) = ext.MinPoint.Z
                    startpoint(1) = ext.MinPoint.Y
                    startpoint(2) = ext.MinPoint.Z + (plot - 0.05) * 1500


                    endpoint(0) = ext.MinPoint.X - 450
                    'endpoint(1) = ext.MinPoint.Y + plot * 1500 - 1200
                    'endpoint(2) = ext.MinPoint.Z
                    endpoint(1) = ext.MinPoint.Y
                    endpoint(2) = ext.MinPoint.Z + plot * 1500

                    Dim myLine As New Line(New Point3d(startpoint(0), startpoint(1), startpoint(2)), New Point3d(endpoint(0), endpoint(1), endpoint(2)))
                    myLine.ColorIndex = 210 - CInt(plot * 20) * 10
                    myLine.LineWeight = 35
                    btr.AppendEntity(myLine)
                    tr.AddNewlyCreatedDBObject(myLine, True)

                    endpoint(2) = ext.MinPoint.Z + plot * 1500 - 75

                    Dim acText2 As DBText = New DBText()
                    acText2.Position = New Point3d(endpoint(0), endpoint(1), endpoint(2))
                    acText2.Height = 50
                    acText2.TextString = " " & CInt(ddd * plot) & "MPa"
                    acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                    btr.AppendEntity(acText2)
                    tr.AddNewlyCreatedDBObject(acText2, True)

                Next

                ed.WriteMessage("graf")

                Dim LoadMngr As IRobotLoadRecordMngr
                Dim Przyp As RobotSimpleCase
                Przyp = robapp.Project.Structure.Cases.Get(4)
                LoadMngr = Przyp.Records
                Dim node As RobotNode = Nothing

                For laster As Double = 1 To LoadMngr.Count
                    Dim Load As IRobotLoadRecord = Nothing
                    Load = LoadMngr.Get(laster)

                    If Load.Type.ToString = "I_LRT_NODE_FORCE" Then

                        Dim lastx As Double = Load.GetValue(0)
                        Dim lasty As Double = Load.GetValue(1)
                        Dim last As Double = -Load.GetValue(2)
                        Dim avstånd As Double = (Math.Abs(lastx) ^ 2 + Math.Abs(lasty) ^ 2 + Math.Abs(last) ^ 2) ^ 0.5

                        'Dim knut As Integer = Load.Objects.Get(laster)
                        Dim knut As Integer = Load.Objects.Get(1)
                        'MsgBox(knut)


                        node = NodeServer.Get(knut)

                        Dim p1 As New Point3d(node.X * 1000, node.Y * 1000, node.Z * 1000)
                        Dim p2 As New Point3d(node.X * 1000 - Load.GetValue(0) / 10, node.Y * 1000 - Load.GetValue(1) / 10, node.Z * 1000 - Load.GetValue(2) / 10)

                        Dim myLine As New Line(p1, p2)
                        myLine.ColorIndex = 1
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)

                        Dim p4 = New Point3d(p1.X - last / 100, p1.Y, p1.Z + last / 100)
                        Dim myLine3 As New Line(p1, p4)
                        myLine3.ColorIndex = 1
                        btr.AppendEntity(myLine3)
                        tr.AddNewlyCreatedDBObject(myLine3, True)

                        p4 = New Point3d(p1.X + last / 100, p1.Y, p1.Z + last / 100)
                        Dim myLine4 As New Line(p1, p4)
                        myLine4.ColorIndex = 1
                        btr.AppendEntity(myLine4)
                        tr.AddNewlyCreatedDBObject(myLine4, True)


                        Dim acText2 As DBText = New DBText()
                        acText2.Position = New Point3d(p2(0) - Len("F=" & CInt(avstånd / 10) / 100 & "kN") * 20, p2(1), p2(2))
                        acText2.Height = 50
                        acText2.TextString = "F=" & CInt(avstånd / 10) / 100 & "kN"
                        acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                        acText2.ColorIndex = 1
                        btr.AppendEntity(acText2)
                        tr.AddNewlyCreatedDBObject(acText2, True)


                    End If
                Next

                ed.WriteMessage("punktlaster")

                Dim I_OT_PANEL As Integer = 4
                Dim I_GOT_CONTOUR As Integer = 2
                Dim RSelection As RobotSelection
                RSelection = robapp.Project.Structure.Selections.Get(I_OT_PANEL)
                Dim PanelCol As RobotObjObjectCollection
                PanelCol = robapp.Project.Structure.Objects.GetMany(RSelection)

                GoTo hoppautbred

                Przyp = robapp.Project.Structure.Cases.Get(3)
                LoadMngr = Przyp.Records
                For laster As Double = 1 To LoadMngr.Count
                    Dim Load As IRobotLoadRecord = Nothing
                    Load = LoadMngr.Get(laster)

                    If Load.Type.ToString = "I_LRT_UNIFORM" Then
                        Dim last As Double = -Load.GetValue(2)
                        Dim på As Integer = Load.Objects.Get(1)

                        Dim Obj As RobotObjObject
                        Dim ContourGeometry As RobotGeoContour
                        Dim Segments As RobotGeoSegmentCollection
                        Dim Segment As RobotGeoSegment

                        'Obj = robapp.Project.Structure.Objects.Get(PanelCol.Get(på).Number)
                        Obj = robapp.Project.Structure.Objects.Get(på)

                        If Obj.Main.GetGeometry.Type = I_GOT_CONTOUR Then

                            ContourGeometry = Obj.Main.GetGeometry
                            Segments = ContourGeometry.Segments

                            Dim acPolyMesh As PolygonMesh = New PolygonMesh
                            acPolyMesh.MSize = 2
                            acPolyMesh.NSize = 4
                            acPolyMesh.MakeNClosed()
                            'What is N???
                            'acPolyMesh.MakeMClosed();
                            'What is M???
                            ' Add the new object to the block table record and the transaction
                            acPolyMesh.ColorIndex = 1
                            btr.AppendEntity(acPolyMesh)
                            tr.AddNewlyCreatedDBObject(acPolyMesh, True)
                            'Creating collection of points to add to the mesh
                            Dim acPts3dPMesh As Point3dCollection = New Point3dCollection
                            For i = 1 To Segments.Count
                                Segment = Segments.Get(i)
                                acPts3dPMesh.Add(New Point3d(Segment.P1.X * 1000, Segment.P1.Y * 1000, Segment.P1.Z * 1000))
                            Next i
                            For i = 1 To Segments.Count
                                Segment = Segments.Get(i)
                                acPts3dPMesh.Add(New Point3d(Segment.P1.X * 1000, Segment.P1.Y * 1000, Segment.P1.Z * 1000 + 100 + last / 10))
                            Next i

                            'Converting those points to PolygonMeshVertecies and appending them to the PolygonMesh
                            For Each acPt3d As Point3d In acPts3dPMesh
                                Dim acPMeshVer As PolygonMeshVertex = New PolygonMeshVertex(acPt3d)
                                acPolyMesh.AppendVertex(acPMeshVer)
                                tr.AddNewlyCreatedDBObject(acPMeshVer, True)
                            Next

                            Dim acText2 As DBText = New DBText()
                            acText2.Position = New Point3d((acPolyMesh.GeometricExtents.MaxPoint.X - Len("F=" & last / 1000 & "kN/m²") * 20 + acPolyMesh.GeometricExtents.MinPoint.X) / 2, (acPolyMesh.GeometricExtents.MaxPoint.Y + acPolyMesh.GeometricExtents.MinPoint.Y) / 2, acPolyMesh.GeometricExtents.MaxPoint.Z + 20)
                            acText2.Height = 50

                            acText2.TextString = "Q=" & last / 1000 & "kN/m²"
                            acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                            acText2.ColorIndex = 1
                            btr.AppendEntity(acText2)
                            tr.AddNewlyCreatedDBObject(acText2, True)

                        End If

                    End If
                    'ed.WriteMessage(vbLf & Load.Type.ToString)


                    If Load.Type.ToString = "I_LRT_BAR_UNIFORM" Then
                        Dim last As Double = -Load.GetValue(2)
                        Dim iknut As Integer = Load.Objects.Get(1)

                        Bar = robapp.Project.Structure.Bars.Get(iknut)
                        Dim bar_num As Integer = Bar.Number

                        node = NodeServer.Get(Bar.StartNode)
                        RNode2 = NodeServer.Get(Bar.EndNode)

                        Dim p1 As New Point3d(node.X * 1000, node.Y * 1000, node.Z * 1000)
                        Dim p2 As New Point3d(RNode2.X * 1000, RNode2.Y * 1000, RNode2.Z * 1000)

                        Dim myLine As New Line(p1, p2)
                        myLine.ColorIndex = 1
                        btr.AppendEntity(myLine)
                        tr.AddNewlyCreatedDBObject(myLine, True)

                        For i As Integer = 0 To myLine.Length Step 100

                            'Dim p3 As Point3d = New Point3d(p1.X + (p2.X - p1.X) / 10 * i, p1.Y + (p2.Y - p1.Y) / 10 * i, p1.Z + (p2.Z - p1.Z) / 10 * i)
                            Dim p3 As Point3d = New Point3d(p1.X + (p2.X - p1.X) / myLine.Length * i, p1.Y + (p2.Y - p1.Y) / myLine.Length * i, p1.Z + (p2.Z - p1.Z) / myLine.Length * i)
                            Dim p4 As Point3d = New Point3d(p3.X, p3.Y, p3.Z + 100 + last / 100)
                            Dim myLine2 As New Line(p3, p4)
                            myLine2.ColorIndex = 1
                            btr.AppendEntity(myLine2)
                            tr.AddNewlyCreatedDBObject(myLine2, True)

                            p4 = New Point3d(p3.X + 10 + last / 1000, p3.Y, p3.Z + 10 + last / 1000)
                            Dim myLine3 As New Line(p3, p4)
                            myLine3.ColorIndex = 1
                            btr.AppendEntity(myLine3)
                            tr.AddNewlyCreatedDBObject(myLine3, True)

                            p4 = New Point3d(p3.X - 10 - last / 1000, p3.Y, p3.Z + 10 + last / 1000)
                            Dim myLine4 As New Line(p3, p4)
                            myLine4.ColorIndex = 1
                            btr.AppendEntity(myLine4)
                            tr.AddNewlyCreatedDBObject(myLine4, True)

                        Next

                        Dim acText2 As DBText = New DBText()
                        Dim textpunkt As Point3d = New Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2 + 110 + last / 100)
                        startpoint(0) = textpunkt.X
                        startpoint(1) = textpunkt.Y
                        startpoint(2) = textpunkt.Z
                        endpoint = PolarPoint(startpoint, myLine.Angle, -Len(last & "N/m") * 40 / 2)
                        acText2.Position = New Point3d(endpoint(0), endpoint(1), endpoint(2))
                        acText2.Height = 50
                        acText2.TextString = last & "N/m"
                        acText2.ColorIndex = 1
                        acText2.TransformBy(Matrix3d.Rotation(Math.PI / 2, curUCS.Xaxis, acText2.Position))
                        btr.AppendEntity(acText2)
                        tr.AddNewlyCreatedDBObject(acText2, True)


                    End If
                    'If Load.Type.ToString = "I_LRT_BAR_TRAPEZOIDALE" Then
                Next
hoppautbred:

                nod_col = Nothing
                serv = Nothing
                tr.Commit()
                robapp.Interactive = True
                robapp = Nothing
            End Using
        End Using
        Me.Close()

    End Sub
Tags (1)
Message 3 of 6
okapawal
in reply to: jokiller70

I don't know about any changes that could affect API performance.

You may speed up API using Interactive flag

okapawal_0-1593091649370.png

 



Waldemar Okapa

Sr Product Owner
Message 4 of 6
jokiller70
in reply to: okapawal

jokiller70_0-1593094299649.png

 

Message 5 of 6
okapawal
in reply to: jokiller70

Did you mean to paste the image to this thread?  This is AutoCAD error report.



Waldemar Okapa

Sr Product Owner
Message 6 of 6
jokiller70
in reply to: okapawal

Yes, dosen´t seem to bee a good idea to make robapp.Interactive = False from within .net

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report