Hey guys, I'm trying to draw this 4 bar-linkage diagram in this link: http://s1113.photobucket.com/albums/k511/Emmcee1/?action=view¤t=Untitled.jpg
This is the outline that I want from it:
' Create a new bar between (x1,y1) and (x2,y2) with a coupling at either end.
' Specify bar and coupling colours using Long constants or RGB(...) calls.
' You must save the result in a Shape variable if you want to move it later.
Function NewBar(ByVal x1 As Double, ByVal y1 As Double, ByVal x2 As Double, ByVal y2 As Double, _ ByVal lngBarColour As Long, ByVal lngCouplingColour As Long) As Shape
End Function
Somehow I tried doing this, but it wouldn't work like nothing pops up in the drawing when I click run. This is what i coded:
Option Explicit
'
' Main subprogram is DrawFigure
' The first part (adding a sheet and removing grid and margin labels) is done for you
' The rest requires you to pick up parameters from named cells,
' to draw 4-bar linkage at specified location, and
' apply fills according to the parameter sheet.
' Cell names. Use wksParams.Range(NAME_CX) etc to obtain cell contents.
Const NAME_CX = "CentreX"
Const NAME_CY = "CentreY"
Sub DrawFigure()
' Local variables
Dim wksParams As Worksheet
Dim shp As Shape
Dim cx As Single, cy As Single
' Identify parameters sheet. Use wksParams.Range(...) rather than ActiveSheet
Set wksParams = Sheets("FigParams")
' Create new clean sheet, this becomes the active sheet
Sheets.Add
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
End With
' Obtain positional parameters from the active sheet
cx = wksParams.Range(NAME_CX).Value
cy = wksParams.Range(NAME_CY).Value
End Sub
Function Aline(x As Single, y As Single) As Shape
Set Aline = ActiveSheet.Shapes.AddShape(msoShapeline… x, y)
End Function
Can anyone help me with another code that might work with this figure?
This is the outline that I want from it:
' Create a new bar between (x1,y1) and (x2,y2) with a coupling at either end.
' Specify bar and coupling colours using Long constants or RGB(...) calls.
' You must save the result in a Shape variable if you want to move it later.
Function NewBar(ByVal x1 As Double, ByVal y1 As Double, ByVal x2 As Double, ByVal y2 As Double, _ ByVal lngBarColour As Long, ByVal lngCouplingColour As Long) As Shape
End Function
Somehow I tried doing this, but it wouldn't work like nothing pops up in the drawing when I click run. This is what i coded:
Option Explicit
'
' Main subprogram is DrawFigure
' The first part (adding a sheet and removing grid and margin labels) is done for you
' The rest requires you to pick up parameters from named cells,
' to draw 4-bar linkage at specified location, and
' apply fills according to the parameter sheet.
' Cell names. Use wksParams.Range(NAME_CX) etc to obtain cell contents.
Const NAME_CX = "CentreX"
Const NAME_CY = "CentreY"
Sub DrawFigure()
' Local variables
Dim wksParams As Worksheet
Dim shp As Shape
Dim cx As Single, cy As Single
' Identify parameters sheet. Use wksParams.Range(...) rather than ActiveSheet
Set wksParams = Sheets("FigParams")
' Create new clean sheet, this becomes the active sheet
Sheets.Add
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
End With
' Obtain positional parameters from the active sheet
cx = wksParams.Range(NAME_CX).Value
cy = wksParams.Range(NAME_CY).Value
End Sub
Function Aline(x As Single, y As Single) As Shape
Set Aline = ActiveSheet.Shapes.AddShape(msoShapeline… x, y)
End Function
Can anyone help me with another code that might work with this figure?