How do I get pattern informations of a pattern placed with "associative pattern" and "associative region boundary" with VBA?
Welcome, Mini!
Please follow the MicroStation Programming forum best practices.
Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8i. What is the 8-digit version number (e.g. 10.xx.yy.zz) of MicroStation?
If you're using MicroStation in a ProjectWise (PW) managed environment, let us know that too.
The APIs supplied with MicroStation CONNECT are different to those supplied with MicroStation V8i. Consequently, our answers are likely to be different.
When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:
Regards, Jon Summers LA Solutions
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,