
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to create a macro which will attach a custom sketched symbol with a leader to some specific parts in a view. By modifying some sample code I managed to create a macro which will attach the sketched symbol to the currently selected edge (see code below). However I would like to select the view and let the code cycle trough all the parts and check the filename or a custom iProperty. If the filename has a certain pattern or a specific custom iProperty exists it should add the sketched symbol. I don't really see how I should do this, I can get a reference to the selected view and as far as I can see I can use the referencedfiledescripter to open the assembly and cycle through the occurences. However I don't see how I can use this to add the sketched symbol to the occurence in the drawing view.
' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet. Dim oActiveSheet As Sheet Set oActiveSheet = oDrawDoc.ActiveSheet ' Set a reference to the drawing curve segment. ' This assumes that a drwaing curve is selected. Dim oDrawingCurveSegment As DrawingCurveSegment Set oDrawingCurveSegment = oDrawDoc.SelectSet.item(1) ' Get the mid point of the selected curve ' assuming that the selection curve is linear Dim oStartPoint As Point2d Set oStartPoint = oDrawingCurveSegment.StartPoint ' Set a reference to the TransientGeometry object. Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry Dim oLeaderPoints As ObjectCollection Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection ' Create a couple of leader points. Call oLeaderPoints.Add(oTG.CreatePoint2d(oStartPoint.X + 2, oStartPoint.Y + 2)) ' Add the GeometryIntent to the leader points collection. ' This is the geometry that the balloon will attach to. Dim oGeometryIntent As GeometryIntent Set oGeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurveSegment.Parent) Call oLeaderPoints.Add(oGeometryIntent) Call oActiveSheet.SketchedSymbols.AddWithLeader("Nozzle Tag", oLeaderPoints)
Any help would be appreciated.
Best regards, Daniël
Solved! Go to Solution.