Get alignment type of an existing drawing view

Get alignment type of an existing drawing view

erichter
Advocate Advocate
291 Views
2 Replies
Message 1 of 3

Get alignment type of an existing drawing view

erichter
Advocate
Advocate

I want to be able to get the alignment type (i.e. vertical, horiztonal, or positional) of an existing drawing view provided that it is aligned, but there doesn't seem to be a way to do this. DrawingView.Aligned only tells me if it's aligned, and DrawingViewAlignmentEnum seems to be write-only. I thought about comparing the position of DrawingView.ParentView, but the parent view is not necessarily the aligned view.

 

Does anyone know how I can get this?

0 Likes
292 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

You can check if there is a parent/child relationship between the views. If so then you can check by position. something like this:

Dim v1 As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select 1e view")
Dim v2 As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select 2e view")

If Not (v1.Aligned Or v2.Aligned) Then
    MsgBox("Not aligned ")
    Return
End If

If (v1.ParentView IsNot v2 And v2.ParentView IsNot v1) Then
    MsgBox("Not aligned (this is not a parent and a child view)")
    Return
End If

Dim alignment = ""
If (Math.Abs(v1.Top - v2.Top) < 0.0000001) Then
    alignment = "horizontal"
ElseIf (Math.Abs(v1.Left - v2.Left) < 0.0000001) Then
    alignment = "vertical"
Else
    alignment = "InPosition"
End If

MsgBox(String.Format(
        "There is a parent/child relation. Acc. to posistion they are {0} aligned.",
        alignment))

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

erichter
Advocate
Advocate

I appreciate the suggestion, but I am trying to get the alignment type through selecting a single view only.

 

Also, if I am selecting two views, then I can check if one of them is aligned and evaluate their positional relationship regardless if they are a parent and child or not. A view having a parent view is independent from what view it's aligned to and thus irrelevant. I only mentioned it in the OP as something I tried but ruled out.

 

By selecting a single view, I would either like to know its alignment type or get the drawing view that it is aligned to so that I can compare their positions to determine the alignment type.

0 Likes