How do I get pattern informations of a pattern placed with "associative pattern" and "associative region boundary" with VBA?
Hi Jacqueline,
Unknown said:How do I get pattern informations of a pattern placed with "associative pattern" and "associative region boundary" with VBA?
There are no such methods / properties in MicroStation VBA available, but you can use PropertyHandler to access parameters availables in Element Information dialog.
If Associative Region Boundary switch is on, a result of patterning is Associative Region, which is impemented as a cell element. So the whole process is to find a proper cell, create property handler and to access values using their Access Strings.
Simple example:
Option Explicit Public Sub GetPatternParams() Dim regionBoundary As CellElement Set regionBoundary = ActiveModelReference.GetElementByID(DLongFromLong(10892)) Dim ph As PropertyHandler Set ph = CreatePropertyHandler(regionBoundary) ph.SelectByAccessString ("HatchAngle") Dim patternAngle As Double patternAngle = ph.GetValue * 180 / Pi MsgBox "Pattern angle: " & patternAngle End Sub
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Mini
I guess it's "HatchSpace", but I recommend to use GetAccessStrings and to study the list of all available access strings.
Dim accessString() As String accessString = ph.GetAccessStrings
I guessed the same, but it doesn't work?
If oPH.SelectByAccessString("HatchSpace") Then spc = oPH.GetValue End If
Unknown said:but it doesn't work?
What does it mean "it doen't work"? Is there any error message or what are symptoms?
Does the access string exist? What variable type is spc?
Unknown said:oPH.SelectByAccessString("HatchSpace") is false
So it means it does not exist ... and you probably dicovered a bug in MicroStation, because the access string exists in the list but cannot be used.
The true is that spacing is not displayed in Element Information dialog also, so maybe this access to hatching is not implemented in V8i (but is enhanced in CONNECT Edition). In such case I am afraid the only way is to use MDL (or at least VBA wrappers for MDL functions). But often it's not simple way.
Unknown said:spc is type double.
Interesting is that spc is also VBA function. Isn't there naming conflict?
Regards,
Unknown said:can you tell me how to use MDL to get the hatch-space?
unfortunately it's not easy. You have to use a proper MDL function (MDL documentation delivered with MicroStation SDK is needed) and to find a right one (I guess it would be probably mdlPattern_extractAssociative). What I am not sure about is that this function fills PatterParams structure and VBA code has to mimics this structure properly. I am worry it would be time consuming task to investigate the right code and test it.
As an alternative, maybe C-expression access to TCB can be used. In TCB (Terminal Control Block, see e.g. this Jon's article) active settings are stored including active pattern parameters. So to obtain pattern spacing value, a workflow identify pattern element > match parameters > check active parameters would work.