Inventor Customization

Inventor Customization

Reply
Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 1 of 6 (239 Views)

Attach sketched symbol to a leadernote

239 Views, 5 Replies
01-14-2013 03:00 AM

Hello

 

Is it possible to attach a sketched symbol to a leader note? I tried the following code, but an error occurs in the line adding the sketchedsymbol. The geometry intent, which seems to be created correct, isn't a valid input for the sketched symbol.

 

Private Sub AttachSketchedSymbolToLeaderNote()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oLeaderNote As LeaderNote
Set oLeaderNote = oDrawDoc.ActiveSheet.DrawingNotes.LeaderNotes.Item(1)

Dim oSketchedSymbolDef As SketchedSymbolDefinition
Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item(1)

Dim oPoint1 As Point2d
Set oPoint1 = oLeaderNote.Position

Dim oPoint2 As Point2d
Set oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(1, 1)

Dim oGeometryIntent As GeometryIntent
Set oGeometryIntent = oDrawDoc.ActiveSheet.CreateGeometryIntent(oLeaderNote, oLeaderNote.Position)

Dim oPoints As ObjectCollection
Set oPoints = ThisApplication.TransientObjects.CreateObjectCollection

Call oPoints.Add(oPoint2)
Call oPoints.Add(oPoint1)
Call oPoints.Add(oGeometryIntent)

Dim oSketchedSymbol As SketchedSymbol
Set oSketchedSymbol = oDrawDoc.ActiveSheet.SketchedSymbols.AddWithLeader(oSketchedSymbolDef, oPoints)

End Sub

 

ADN Support Specialist
xiaodong.liang
Posts: 1,335
Registered: ‎06-12-2011
Message 2 of 6 (227 Views)

Re: Attach sketched symbol to a leadernote

01-15-2013 05:53 PM in reply to: krieg

Hi,

 

although having not digged into, I suspected this is similar to the other case, in which I wrote a blog for it. Could you take a look if it helps?

 

Connecting Sketchedsymbol to Balloon using VB 

 

http://adndevblog.typepad.com/manufacturing/2013/01/attach-a-sketched-symbol-to-a-balloon.html

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 3 of 6 (217 Views)

Re: Attach sketched symbol to a leadernote

01-16-2013 01:12 PM in reply to: xiaodong.liang

Hello

 

This blog post is source/inspiration of my code. Also your example code fails here in the line

Call oSS.Leader.AddLeader(oObjColl)

 with

 

Run-time error -2147467259 (80004005)
Method 'AddLeader' of object 'Leader' failed

 

Tested it with Inventor 2011 and 2013 all ServicePacks installed.

 

Love these days :smileysad:

 

 

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 4 of 6 (214 Views)

Re: Attach sketched symbol to a leadernote

01-16-2013 01:47 PM in reply to: krieg

Hello

 

I figured out the problem with your code. Don't know why, but balloon diameter value here is not the diameter, but the radius of the balloon.

 

Maybe there's a similar problem with the coordinates in my code. Will do some testing.

ADN Support Specialist
xiaodong.liang
Posts: 1,335
Registered: ‎06-12-2011
Message 5 of 6 (192 Views)

Re: Attach sketched symbol to a leadernote

01-20-2013 07:52 PM in reply to: krieg

Hi,

 

I am not clear what you met with. As you can see, my code uses diameter/ 2.0 to get radius. It works well with my simplest sample balloon. probably you are testing a specific sample?

 

this is just for your reference to figure out the problem of attach symbol to leader note because I doubt we can only attach to some specific location of the leader note (like balloon). Hope this helps. If you worked out, please update this post. I would be useful for others. Thanks!



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 6 of 6 (186 Views)

Re: Attach sketched symbol to a leadernote

01-21-2013 04:29 AM in reply to: xiaodong.liang

Hello

 

Sorry, my fault. I forgot to set ScaleToTextHeight=false. So the diameter value couldn't be right. :smileysad:

 

I did some further testing. The GUI accepts a non visible square around the LeaderNote text as input to attach the leader of my sketched symbol. If i copy'n paste the coordinates of the manual added leader to my code it won't work. I've attached a screenshot.

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.