I was originally planning to ask this question on the Bentley forums for programming as they had a similar answer for a C# question which I was using to model mine on. However, the account I created for the forums doesn't seem to be working.
The purpose of the code is to set the linestyle, color, lineweight and then lastly two settings which are classified under Line Style Parametra and known as Scale and Corner Mode.
As background, I'm far more familiar with C# than VBA and that might be causing me to miss something, but the solution that I have feels similar to the C# approach highlighted in the link above (which I very serendipitously found):
Private Sub AdjustStyleToByLevel(lvlName As String)
' Set up level definitions
Dim oLevel As Level
Set oLevel = ActiveDesignFile.Levels(lvlName)
' Set up scan criteria
Dim oScanCriteria As ElementScanCriteria
Set oScanCriteria = New ElementScanCriteria
oScanCriteria.ExcludeAllLevels
oScanCriteria.IncludeLevel oLevel
Dim oEnumerator As ElementEnumerator
Set oEnumerator = ActiveModelReference.Scan(oScanCriteria)
Dim oElement As Element
Do While oEnumerator.MoveNext
Set oElement = oEnumerator.Current
If oElement.IsTraversableElement Then
Dim oLineElement As LineElement
Set oLineElement = oElement
Set oLineElement.LineStyle = ByLevelLineStyle
oLineElement.Color = ByLevelColor ' -1
oLineElement.LineWeight = ByLevelLineWeight ' -1
' Define and set the Line Style settings
Dim oParams As LineStyleParameters
Set oParams = oElement.GetLineStyleParameters
oParams.ScaleFactor = Share.ChartScale / 100
oParams.SetRunThroughCorners
oLineElement.SetLineStyleParameters (oParams)
oLineElement.Rewrite
End If
Loop
End Sub
It's the line oLineElement.SetLineStyleParameters (oParams)
that gives me the error 438: 'Object does not support this method or property'. However, when comparing this to the C# approach mentioned above (quoted below), I fail to notice a major difference.
public void ChangeLineStyleScale()
{
BCOM.Application msApp = BMI.Utilities.ComApp;
BCOM.LineElement oLine = msApp.ActiveModelReference.GetElementByID64(15092) as BCOM.LineElement;
BCOM.LineStyleParameters lsParams = oLine.GetLineStyleParameters();
lsParams.ScaleFactor = 2.0;
oLine.SetLineStyleParameters(lsParams);
oLine.Rewrite();
}
Does anyone know what I am doing wrong here, or how to solve this issue?
Thanks
Answer was provided by Jan Slegr on Bentley forums to which I finally got access.
Parenthesis are not used in VBA if a method is called without set =, so you have to remove them:
oLineElement.SetLineStyleParameters oParams