0% found this document useful (0 votes)
5 views1 page

Grasp

The document contains a VBA subroutine for plotting the deformed shape of a structure based on member displacements. It calculates the original and deformed positions of nodes, scales the displacements, and adds the deformed shape to a chart. An error handler is also included to display a message box in case of errors during the plotting process.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Grasp

The document contains a VBA subroutine for plotting the deformed shape of a structure based on member displacements. It calculates the original and deformed positions of nodes, scales the displacements, and adds the deformed shape to a chart. An error handler is also included to display a message box in case of errors during the plotting process.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exit Sub

ErrorHandler:
MsgBox "Error in 3D plotting: " & Err.Description, vbCritical, "GRASP
Error"
End Sub

' Plot deformed shape


Sub PlotDeformedShape(cht As ChartObject)
Dim mem As clsMember
Dim startNode As clsNode, endNode As clsNode
Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
Dim dx1 As Double, dy1 As Double, dz1 As Double
Dim dx2 As Double, dy2 As Double, dz2 As Double
Dim scaleFactor As Double: scaleFactor = 50 ' Scale factor for
displacements

For Each mem In MemberList


Set startNode = NodeList(mem.StartNode)
Set endNode = NodeList(mem.EndNode)

' Get displacements


dx1 = DisplacementList(mem.StartNode).dx * scaleFactor
dy1 = DisplacementList(mem.StartNode).dy * scaleFactor
dz1 = DisplacementList(mem.StartNode).dz * scaleFactor

dx2 = DisplacementList(mem.EndNode).dx * scaleFactor


dy2 = DisplacementList(mem.EndNode).dy * scaleFactor
dz2 = DisplacementList(mem.EndNode).dz * scaleFactor

' Project original and deformed positions


Dim origX1 As Double, origY1 As Double
Dim origX2 As Double, origY2 As Double
Dim defX1 As Double, defY1 As Double
Dim defX2 As Double, defY2 As Double

Project3Dto2D startNode.X, startNode.Y, startNode.Z, origX1, origY1


Project3Dto2D endNode.X, endNode.Y, endNode.Z, origX2, origY2)

Project3Dto2D startNode.X + dx1, startNode.Y + dy1, startNode.Z +


dz1, defX1, defY1
Project3Dto2D endNode.X + dx2, endNode.Y + dy2, endNode.Z + dz2,
defX2, defY2)

' Add deformed shape series


With cht.Chart.SeriesCollection.NewSeries
.Name = "Deformed " & mem.MemberID
.XValues = Array(defX1, defX2)
.Values = Array(defY1, defY2)
.MarkerStyle = xlMarkerStyleCircle
.MarkerSize = 4
.Border.Color = RGB(255, 0, 0) ' Red for deformed shape
End With
Next mem

' Add legend entry for deformed shape

P a g e 40 | 57

You might also like