Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Sketch Symbol

MattH_Work
Collaborator

Sketch Symbol

MattH_Work
Collaborator
Collaborator

Is it possible to get the name of a view that a sketch symbol is attached to

 

I know the symbol, can i get the curve its attached to, and from there get the view that the curve belongs to

 

cheers

 

MattH


MattH
Product Design Collection 2025
Vault Pro 2025
0 Likes
Reply
911 Views
7 Replies
Replies (7)

rikard.nilsson
Collaborator
Collaborator

Hi,

 

I'm assuming that the Sketched Symbol has a leader, becuase I don't know how to attach a symbol in any other way..

 

But here is a quick way to find the view name. This is the one that I came up with anyway..

I hope that it will help you..

 

Regards

Rikard

 

Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet
Dim symbol as SketchedSymbol
For Each item in oSheet.SketchedSymbols
    If item.Name = "Test" Then
        symbol = item
        Exit For
    End If
Next

Dim rn As LeaderNode = symbol.leader.AllNodes.Item(2)
Dim geoInt As GeometryIntent  = rn.AttachedEntity
Dim DC As DrawingCurve = geoInt.Geometry

For Each oView In oSheet.DrawingViews
        Dim LeftX As Double = oView.Left
        Dim RightX As Double = LeftX + oView.Width
        Dim TopY As Double = oView.Top
        Dim BottomY As Double = TopY-oView.Height
        
        If DC.MidPoint.x >= LeftX And DC.MidPoint.x <= RightX And DC.MidPoint.y >= BottomY And DC.MidPoint.y <= TopY Then
             MessageBox.Show(oView.Name, "Title")
            Exit For
        End If
Next  

 

0 Likes

MattH_Work
Collaborator
Collaborator

Unfortunately my symbols don't use leaders, they are attached directly to the geometry, also there are two symbols per sheet, and the views they are attached to are not necessarily it two distinct positions on the sheet, ie they may overlap which then causes your code to report the same view for both symbols

 

Thanks anyway

 

Matt


MattH
Product Design Collection 2025
Vault Pro 2025
0 Likes

frederic.vandenplas
Collaborator
Collaborator

hi @MattH_Work this should work

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

Dim symbol As SketchedSymbol
For Each symbol In oSheet.SketchedSymbols
    If symbol.Name = "test" Then
         MsgBox( symbol.Parent.DrawingViews(1).Name)
       
    End If
Next

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes

rikard.nilsson
Collaborator
Collaborator
Hi,

Interesting solution.
I thought that the Sheet was the parent of a sketched symbol.

If that solution won't work. I would like to have an example drawing. To se how you have attached a symbol without leader.
When I tried that, it would not get attached just placed on the curve but after moving the view, the symbol did not move.

I think it's possible to work our way up from a drawing curve to the view by code and not use my quick way of just checking the coordinate. But for that I really need to be attached.

/Rikard
0 Likes

frederic.vandenplas
Collaborator
Collaborator
Hi,

If it attached to a line in the view, the parent is indeed the view, otherwise it could be the sheet
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes

rikard.nilsson
Collaborator
Collaborator

Hi,

 

This is not my thread.. But I've tested your solution and I can't get any other answer that the messagebox shows only the first view on the sheet.

 

I've tested by placing a Symbol to a line the second view on the sheet.

I've also tested by using a leader that points to a line in the second view and it still gives me the first view name..

 

So I think I'm right when I say that the Parent to a symbol is the Sheet and not the view..

 

It's would be really nice to se how you solved this. Can you add an example?

 

/Rikard

0 Likes

MechMachineMan
Advisor
Advisor

There is no easy solution for this.

 

I checked using the VBA editor to see what objects are accessible from the SketchedSymbol, and the parent is in fact always the sheet.

 

Also, there is never any view information that gets associated with the sketched symbol; the closest you can get is the coordinates of the leader points which attach it to something.

 

This leaves you with the whole trouble of trying to find what object on the sheet actually has a line or point at those same coordinates.

 

This means Rikard's solution is likely as close as you are going to get unless you find a better way to get the associated object for 2 given work points.

 

Good luck.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes