Sketched Symbol Moves with Drawing View - No Locals Window Connection VBA

Sketched Symbol Moves with Drawing View - No Locals Window Connection VBA

Tiffany_Hayden_
Collaborator Collaborator
423 Views
6 Replies
Message 1 of 7

Sketched Symbol Moves with Drawing View - No Locals Window Connection VBA

Tiffany_Hayden_
Collaborator
Collaborator

Hi, I'm wondering if anyone has successfully found anything in the locals window to link between a sketched symbol that is connected to the view. If you move the view the symbol moves with the view. So it must know that it is connected to the view somehow. But I can't seem to find anything in the locals window to tell me this sketched symbol is connected to this view or this view has this sketched symbol attached to it. Any help would be greatly appreciated. 

 

Thank you!

 

TiffanyHaydenSWQYG_0-1647636654110.png

 

Tiffany Hayden
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

0 Likes
424 Views
6 Replies
Replies (6)
Message 2 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

Check the SketchedSymbol.Leader.AllLeafNodes.Item(x).AttachedEntity. There you can see to which geometry the symbol is attached and check to which view the geometry belongs.

EDIT: If you delete the leader, you can't see the connection anymore. I think that's just another part of a little piece of missing API.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 7

Tiffany_Hayden_
Collaborator
Collaborator

@Ralf_Krieg So the issue I'm having is the attached entity is the centerline that is included in the view. If the symbol is attached to a centerline and the centerline is included in a specific view how do I get the view from either the centerline or the symbol? Both the centerline and symbol are attached to the view because when I move the view they both move. 

 

TiffanyHaydenSWQYG_1-1647866760554.png

 

 

Tiffany Hayden
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

0 Likes
Message 4 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

This gets the drawing view, for this one special case.

 

Private Sub GetView()
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    Dim oSketchedSymbol As SketchedSymbol
    Set oSketchedSymbol = ThisApplication.CommandManager.Pick(kDrawingSketchedSymbolFilter, "Pick a sketched symbol.")

    Dim oCenterline As Centerline
    Set oCenterline = oSketchedSymbol.Leader.AllLeafNodes(1).AttachedEntity.Geometry

    Dim oView As DrawingView
    Set oView = oCenterline.FitPoints(1).Geometry.Parent
End Sub

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 7

Tiffany_Hayden_
Collaborator
Collaborator

@Ralf_Krieg My fitpoints is <Application-definied or object-defined error>

 

TiffanyHaydenSWQYG_0-1647869029735.png

 

Tiffany Hayden
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

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

Your Centerline is created another way. I can't reproduce how, but CenterlineType differs. As there are so many different possibilities a leader could be attached, there's no single way. The real "link" between view and symbol is not offered by API.

I had an alternative idea. What if simply check the Leader.AllLeafNodes(1).Position. This is a Point2D and if the Leader is attached to anything on the view, this point is inside the view limits. Even if the leader is not attached, but ends somewhere inside the view, the result is correct. Only if there's no leader, we will not get this point. We can additionally use the SketchedSymbol.Position point, but it must not be inside view limits. And if there is more than one leader pointing to different views, the result could be false.

 

Here's a snippet that demonstrate the above

Private Sub GetView()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet

Dim oSketchedSymbol As SketchedSymbol
Set oSketchedSymbol = ThisApplication.CommandManager.Pick(kDrawingSketchedSymbolFilter, "Pick a sketched symbol.")

Dim oPoint As Point2d
Set oPoint = oSketchedSymbol.Leader.AllLeafNodes(1).Position

Dim oDrawView As DrawingView
For Each oDrawView In oSheet.DrawingViews
    Dim MinX As Double
    Dim MaxX As Double
    Dim MinY As Double
    Dim MaxY As Double
    
    MinX = oDrawView.Left
    MaxX = oDrawView.Left + oDrawView.Width
    MinY = oDrawView.Top - oDrawView.Height
    MaxY = oDrawView.Top
    
    If MinX <= oPoint.X And oPoint.X <= MaxX And MinY <= oPoint.Y And oPoint.Y <= MaxY Then
        MsgBox ("Sketched symbol is on view " & oDrawView.Name)
    End If
Next

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

Tiffany_Hayden_
Collaborator
Collaborator

@Ralf_Krieg Yes I'm already examining the endpoints/startpoints of centerlines or position of the symbol to determine which view it's attached to. I was just wanting to make sure there wasn't an API call to say this centerline is attached to this view. Seems like there isn't. Good to know. Good to know that I'm not doing a workaround for no reason. 🙂 Thanks for your help! 

Tiffany Hayden
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

0 Likes