Issue with GeometryIntent while Attaching a sketched symbol to an Existing sketched Symbol

Issue with GeometryIntent while Attaching a sketched symbol to an Existing sketched Symbol

gopinadh7XTGG
Contributor Contributor
672 Views
2 Replies
Message 1 of 3

Issue with GeometryIntent while Attaching a sketched symbol to an Existing sketched Symbol

gopinadh7XTGG
Contributor
Contributor

Hello All,

 

I was trying to insert & attach a new sketch symbol to an existing sketch symbol as associative like when I move existing sketch symbol, new symbol has to move accordingly. The below code is creating geometry intent but when I pass the geometry intent as an ObjectCollection for leader points it is failing with error 'Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))'.  
Geometry intent while attaching sketch symbol to other entities such as Drawing curve, balloon or dimensions is working fine, but while attaching sketch symbol to an Existing sketch Symbol is failed.
Any help is appreciated.

Inventor.Application oApp = Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;

    DrawingDocument drawingDocument = oApp.ActiveDocument as DrawingDocument;

    SketchedSymbol existingSketchedSymbol = oApp.CommandManager.Pick(SelectionFilterEnum.kDrawingSketchedSymbolFilter, "Select Existing Symbol to Attach to") as SketchedSymbol;

    Point2d existingSymbolPositionPoint = existingSketchedSymbol.Position;

    //SketchedSymbolDefinition existingSymbolDefinition = existingSketchedSymbol.Definition;

    DrawingSketch sketch = existingSketchedSymbol.Definition.Sketch;

    SketchLines AllSketchLines = sketch.SketchLines;

    Dictionary<double, SketchLine> Sketchlines = new Dictionary<double, SketchLine>();

    foreach (SketchLine sketchLine in AllSketchLines)
    {
        Sketchlines.Add(sketchLine.Length, sketchLine);
    }

    double lengthFromSketchDefinition = Sketchlines.OrderByDescending(x => x.Key).ToDictionary(x => x.Key, y => y.Value).First().Key;

    Point2d existingSymbolEndpoint = oApp.TransientGeometry.CreatePoint2d(existingSymbolPositionPoint.X - lengthFromSketchDefinition, existingSymbolPositionPoint.Y);

    string NameofNewSymbol = "Tail LH";

    SketchedSymbolDefinition oSketchedSymbolDeff = drawingDocument.SketchedSymbolDefinitions[NameofNewSymbol];

    GeometryIntent geometryIntent = drawingDocument.ActiveSheet.CreateGeometryIntent(existingSketchedSymbol, existingSymbolEndpoint);

    ObjectCollection Leaderpoints = oApp.TransientObjects.CreateObjectCollection();

    Leaderpoints.Add(existingSymbolEndpoint);
    Leaderpoints.Add(geometryIntent);

    //Leaderpoints.Add(geometryIntent.PointOnSheet);

    SketchedSymbol NewSketchedSymbol = drawingDocument.ActiveSheet.SketchedSymbols.AddWithLeader(oSketchedSymbolDeff, Leaderpoints, 0, 1, null, true, true);
 
 
Thanks,
GopinadhGvs.
673 Views
2 Replies
Replies (2)
Message 2 of 3

amitabhVA4SD
Advocate
Advocate

@MjDeck @johnson.shiue - Inventor team help!

Message 3 of 3

J_Pfeifer_
Advocate
Advocate

Did anyone figure this one out? I've tried passing multiple points, changing the geometry intent, and the geometry itself in an attempt to create a sketched symbol of a specific center point to a drawing view in order to lock that center mark to the center of the view. Most if not all the examples I can dig up with examples are always trying to attach a sketched symbol to a drawing curve or line within the view. This is not my intention, but makes me think there's some kind of limitation to what a leader can be attached to. 

 

 

 

	
	'This could be improved with placement and size options upon placement and creation
	Dim Page3TopViewPoint As Point2d = oTG.CreatePoint2d(oPage3.Width / 2, oPage3.Height / 2)
	
	'Below is the creation of the page three top view
	 Dim SectionView As Inventor.SectionDrawingView = oPage3.DrawingViews.AddSectionView(oNewView1, Page2SectionSketch, Page3TopViewPoint, ViewStyle, oScale * 2, Nothing, Nothing, False, True, -10)
	 
	SectionView.ReverseDirection 'This flips the direction of the section view sketch for use to direct the view orientation.
	
	'This center orientaion needs to be changed and turned into a sketch upon the drawing object itself for proper constraint to the view. 
	Dim CenterTopSketchDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Center orientation")
	Dim oLeaderpoint As Point2d = oTG.CreatePoint2d(SectionView.Position.X, SectionView.Position.Y)
	Dim SymGeoIntent As GeometryIntent = oPage3.CreateGeometryIntent(SectionView.Center, Inventor.IntentTypeEnum.kPoint2dIntent)
	Dim SymLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	Call SymLeaderPoints.Add(SymLeaderPoint)
	Call SymLeaderPoints.Add(SymGeoIntent)
	
	'Logger.Info("SymLeaderPoint: " & SymLeaderPoint.X.ToString & ", " & SymLeaderPoint.Y)
	'Logger.Info("SymLeaderPoint1: " & SymLeaderPoint1.X.ToString & ", " & SymLeaderPoint1.Y.ToString)
	Logger.Info("SymGeoIntent: " & SymGeoIntent.Type.ToString & ", " & SymGeoIntent.PointOnSheet.ToString & " Intent Type: " & SymGeoIntent.IntentType.ToString)
	Logger.Info("CenterTopSketchDef: " & CenterTopSketchDef.Name)
	
	
	
	
	 Dim CenterTopSketch As SketchedSymbol = oPage3.SketchedSymbols.AddWithLeader(CenterTopSketchDef, SymLeaderPoints)
	
	
	'Dim CenterTopSketch As SketchedSymbol = oPage3.SketchedSymbols.Add(CenterTopSketchDef, Page3TopViewPoint, Nothing, 1, Nothing)
	
	Logger.Info("Has root node y/n: " & CenterTopSketch.Leader.HasRootNode.ToString)
	
	
	SectionView.ShowLabel = True
	SectionView.Label.ConstrainToBorder = True

 

Note: This code is a mess due to me trying to move and change things constantly. I doubt this can even create the symbol on the sheet currently. 

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/sketched-symbol-attached-entity/td-p/1766...

https://forums.autodesk.com/t5/inventor-forum/positioning-sketched-symbols/td-p/3545706

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-D99C6989-817B-4592-9A7A-F4DE86116E29

 

This last link specifies that you should be able to edit and turn on the leader line by default. I've found unfortunately the check box for the leader only appears when you have right clicked and attached a leader to the sketched symbol. Having a leader inside the base object of the sketched symbol seems impossible. 

 

@A.Acheson 

@WCrihfield 

@Curtis_Waguespack 

 

0 Likes