Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Annotate component part numbers without leaders

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
mat_hijs
1583 Views, 14 Replies

Annotate component part numbers without leaders

mat_hijs
Collaborator
Collaborator

I'm looking for a way to annotate the part numbers of components in an assembly on a drawing.

My goal is to have an annotation which is placed on the center of the component without a leader, comparable to Revit. Basically a balloon, attached to the center of a component, and without a leader.

From what I understand balloons in Inventor are always attached to an edge, and the only way to have a balloon without a leader is by placing the balloon itself right on the arrow. This is not exactly what I want, since I don't really want it attached to an edge.

I've thought about using leader notes or sketch symbols, but I'm not sure what woud be my best bet.

The end goal would be to have a tool like auto balloon, but have it place annotations on the components instead of placing them around the assembly using leaders.

Keeping the link between part number and annotation is a must.

 

Anyone has an idea where to go with this?

0 Likes

Annotate component part numbers without leaders

I'm looking for a way to annotate the part numbers of components in an assembly on a drawing.

My goal is to have an annotation which is placed on the center of the component without a leader, comparable to Revit. Basically a balloon, attached to the center of a component, and without a leader.

From what I understand balloons in Inventor are always attached to an edge, and the only way to have a balloon without a leader is by placing the balloon itself right on the arrow. This is not exactly what I want, since I don't really want it attached to an edge.

I've thought about using leader notes or sketch symbols, but I'm not sure what woud be my best bet.

The end goal would be to have a tool like auto balloon, but have it place annotations on the components instead of placing them around the assembly using leaders.

Keeping the link between part number and annotation is a must.

 

Anyone has an idea where to go with this?

14 REPLIES 14
Message 2 of 15
theo.bot
in reply to: mat_hijs

theo.bot
Collaborator
Collaborator

If you use skeched symbols in a drawing, you can place them with a invisible leader. This keeps your symbol linked to the component that you want to reference. you can reposition the symbol but no leader will be visible.

 

theobot_0-1636966526644.png

 

0 Likes

If you use skeched symbols in a drawing, you can place them with a invisible leader. This keeps your symbol linked to the component that you want to reference. you can reposition the symbol but no leader will be visible.

 

theobot_0-1636966526644.png

 

Message 3 of 15
Michael.Navara
in reply to: mat_hijs

Michael.Navara
Advisor
Advisor

You are not able to remove a leader from balloon, but you can set leader style of balloon to "almost" hidden (No arrow, line style doted) In this case you can use standard balloon for annotation. Inventor has connected component and the visual style is acceptable for viewing or printing.

 

michaelnavara_0-1636966795942.png

Sorry for printscreen from CZ version

michaelnavara_1-1636966909063.png

 

You are not able to remove a leader from balloon, but you can set leader style of balloon to "almost" hidden (No arrow, line style doted) In this case you can use standard balloon for annotation. Inventor has connected component and the visual style is acceptable for viewing or printing.

 

michaelnavara_0-1636966795942.png

Sorry for printscreen from CZ version

michaelnavara_1-1636966909063.png

 

Message 4 of 15
mat_hijs
in reply to: mat_hijs

mat_hijs
Collaborator
Collaborator

@theo.bot @Michael.Navara Both these options seem to be able to achieve more or less the result I want for an annotation. But is there a possibility to place these in bulk and have them placed at the center of the model? So like the auto balloon function, but have every balloon or sketch symbol placed at the center of the model it's referencing.

I would like to be able to run a rule (or macro) that does exactly this.

I would imagine I'd have to somehow loop through each occurrence that's visible in the selected view and add my annotation to them, but every example I've found so far uses a drawing curve to place the annotation and uses that drawing curve to find out which occurrence it is. I believe I want to do the opposite, find the occurrence and then attach to a drawing curve from that model, and then somehow place the annotation at the center of the model.

If any of you could help me get started with this that would be great!

0 Likes

@theo.bot @Michael.Navara Both these options seem to be able to achieve more or less the result I want for an annotation. But is there a possibility to place these in bulk and have them placed at the center of the model? So like the auto balloon function, but have every balloon or sketch symbol placed at the center of the model it's referencing.

I would like to be able to run a rule (or macro) that does exactly this.

I would imagine I'd have to somehow loop through each occurrence that's visible in the selected view and add my annotation to them, but every example I've found so far uses a drawing curve to place the annotation and uses that drawing curve to find out which occurrence it is. I believe I want to do the opposite, find the occurrence and then attach to a drawing curve from that model, and then somehow place the annotation at the center of the model.

If any of you could help me get started with this that would be great!

Message 5 of 15
mat_hijs
in reply to: mat_hijs

mat_hijs
Collaborator
Collaborator

I'm going with sketch symbols now as this seemed to be the most flexible way of doing this. I'm at a point where I can loop through each occurrence, create a sketch symbol and place it on the center of mass.

My first issue is that the sketch symbol isn't attached to the occurrence yet, so they all just show the part number of the main assembly. I'm trying to figure out how to get the geometry intent without having to manually select a drawing curve segment.

My second issue is that this will loop through all occurrences, whether they are visible in that view or not, and annotate them, there should probably be some kind of check to see if that occurrence is visible in that view.

 

Here's the code I've got so far:

'[ Define properties of the Sketch Symbol
' Define the name of the Sketch Symbol Definition
Dim sSketchSymbolDef As String = "Part Number"

' Define the rotation of the Sketch Symbol
Dim oRotation As Double = 0

' Define the scale of the Sketch Symbol
Dim oScale As Double = 1

'Define whether the Sketch Symbol is static or not
Dim bStatic As Boolean = True
']

' Set a reference to the Drawing Document
Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument

' Set a reference to the Active Sheet
Dim oSheet As Sheet = oDrawingDoc.ActiveSheet

' Set a reference to the selected Drawing View
'Dim oDrawingView As DrawingView = ActiveSheet.View("VIEW1").View ' Use this line instead of the next one to select Drawing View based on the name
Dim oDrawingView As DrawingView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select Drawing View") ' Use this line instead of the prevous one to select Drawing View while running the rule

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition

' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
	
	' Set a reference to the centerpoint of the model
	Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass
	
	' Convert the centerpoint of the model to a point on the sheet
	Dim oPositionPoint As Point2d = oDrawingView.ModelToSheetSpace(oOccCenterPoint)

	' Set a reference to the Sketch Symbol Definition
	Dim oSketchSymbolDef As SketchedSymbolDefinition = oDrawingDoc.SketchedSymbolDefinitions.Item(sSketchSymbolDef)

	' Place a Sketch Symbol
	Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, oRotationDegrees * PI / 180, oScale)
		oSketchSymbol.Static = bStatic
Next
0 Likes

I'm going with sketch symbols now as this seemed to be the most flexible way of doing this. I'm at a point where I can loop through each occurrence, create a sketch symbol and place it on the center of mass.

My first issue is that the sketch symbol isn't attached to the occurrence yet, so they all just show the part number of the main assembly. I'm trying to figure out how to get the geometry intent without having to manually select a drawing curve segment.

My second issue is that this will loop through all occurrences, whether they are visible in that view or not, and annotate them, there should probably be some kind of check to see if that occurrence is visible in that view.

 

Here's the code I've got so far:

'[ Define properties of the Sketch Symbol
' Define the name of the Sketch Symbol Definition
Dim sSketchSymbolDef As String = "Part Number"

' Define the rotation of the Sketch Symbol
Dim oRotation As Double = 0

' Define the scale of the Sketch Symbol
Dim oScale As Double = 1

'Define whether the Sketch Symbol is static or not
Dim bStatic As Boolean = True
']

' Set a reference to the Drawing Document
Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument

' Set a reference to the Active Sheet
Dim oSheet As Sheet = oDrawingDoc.ActiveSheet

' Set a reference to the selected Drawing View
'Dim oDrawingView As DrawingView = ActiveSheet.View("VIEW1").View ' Use this line instead of the next one to select Drawing View based on the name
Dim oDrawingView As DrawingView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select Drawing View") ' Use this line instead of the prevous one to select Drawing View while running the rule

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition

' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
	
	' Set a reference to the centerpoint of the model
	Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass
	
	' Convert the centerpoint of the model to a point on the sheet
	Dim oPositionPoint As Point2d = oDrawingView.ModelToSheetSpace(oOccCenterPoint)

	' Set a reference to the Sketch Symbol Definition
	Dim oSketchSymbolDef As SketchedSymbolDefinition = oDrawingDoc.SketchedSymbolDefinitions.Item(sSketchSymbolDef)

	' Place a Sketch Symbol
	Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, oRotationDegrees * PI / 180, oScale)
		oSketchSymbol.Static = bStatic
Next
Message 6 of 15
Ralf_Krieg
in reply to: mat_hijs

Ralf_Krieg
Advisor
Advisor

Hello

 

Simpliest way would be try to get DrawingCurves(oOcc). If none occurrence ist not visible, otherwise pick on the drawingcurves for your geometryintent.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
0 Likes

Hello

 

Simpliest way would be try to get DrawingCurves(oOcc). If none occurrence ist not visible, otherwise pick on the drawingcurves for your geometryintent.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 7 of 15
theo.bot
in reply to: Ralf_Krieg

theo.bot
Collaborator
Collaborator
Accepted solution

You also need to add a leader to your symbol to connect it to your component. Like @Ralf_Krieg  mentioned you can use the drawing curve from the occurrence.
Here is a sample, you might tweak the code and need add some additional checks in the code. 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

' Set a reference to Active sheet
Dim oSheet As Sheet 
oSheet = oDoc.ActiveSheet

' Set a reference to first Drawing view
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)

' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

'create a object collection for leader points
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition
Logger.Info(oMainAsm.DisplayName)
' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
logger.Info(oOcc.Name)
		' Set a reference to the centerpoint of the model
		Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass

		' Convert the centerpoint of the model to a point on the sheet
		Dim oPositionPoint As Point2d = oView.ModelToSheetSpace(oOccCenterPoint)

		If oView.DrawingCurves(oOcc).Count <> 0 Then

			oLeaderPoints.Clear

			' The found curve is a drawing curve segment so we need to get the drawing curve.
			Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)
			
			'Get the midpoint from the curve
			Dim oGI1 As GeometryIntent
			oGI1 = oDoc.ActiveSheet.CreateGeometryIntent(curve, kCenterPointIntent)

			oLeaderPoints.Add(oPositionPoint)
			oLeaderPoints.Add(oGI1)

			' Set a reference to the Sketch Symbol Definition
			Dim oSketchSymbolDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("PartNumber")

			' Place a Sketch Symbol
			Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, 0, 1)
			oSketchSymbol.Static = True
			oSketchSymbol.Leader.AddLeader(oLeaderPoints)
			oSketchSymbol.LeaderVisible = False
			oSketchSymbol.Name = oOcc.Name
		End If

Next

 

theobot_0-1637057130748.png

 

With a large assembly it can be a mess adding all notes in one view, using the occurences can result in multiple symbols. So you might want to skip multiple instances.

theobot_1-1637057278837.png

 

0 Likes

You also need to add a leader to your symbol to connect it to your component. Like @Ralf_Krieg  mentioned you can use the drawing curve from the occurrence.
Here is a sample, you might tweak the code and need add some additional checks in the code. 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

' Set a reference to Active sheet
Dim oSheet As Sheet 
oSheet = oDoc.ActiveSheet

' Set a reference to first Drawing view
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)

' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

'create a object collection for leader points
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition
Logger.Info(oMainAsm.DisplayName)
' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
logger.Info(oOcc.Name)
		' Set a reference to the centerpoint of the model
		Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass

		' Convert the centerpoint of the model to a point on the sheet
		Dim oPositionPoint As Point2d = oView.ModelToSheetSpace(oOccCenterPoint)

		If oView.DrawingCurves(oOcc).Count <> 0 Then

			oLeaderPoints.Clear

			' The found curve is a drawing curve segment so we need to get the drawing curve.
			Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)
			
			'Get the midpoint from the curve
			Dim oGI1 As GeometryIntent
			oGI1 = oDoc.ActiveSheet.CreateGeometryIntent(curve, kCenterPointIntent)

			oLeaderPoints.Add(oPositionPoint)
			oLeaderPoints.Add(oGI1)

			' Set a reference to the Sketch Symbol Definition
			Dim oSketchSymbolDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("PartNumber")

			' Place a Sketch Symbol
			Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, 0, 1)
			oSketchSymbol.Static = True
			oSketchSymbol.Leader.AddLeader(oLeaderPoints)
			oSketchSymbol.LeaderVisible = False
			oSketchSymbol.Name = oOcc.Name
		End If

Next

 

theobot_0-1637057130748.png

 

With a large assembly it can be a mess adding all notes in one view, using the occurences can result in multiple symbols. So you might want to skip multiple instances.

theobot_1-1637057278837.png

 

Message 8 of 15
mat_hijs
in reply to: theo.bot

mat_hijs
Collaborator
Collaborator

Thanks a lot! This set me on the right track and I got it working now. This line is basically what I was looking for:

Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)

 In the cases where I want to use this there won't be a problem with getting messy. I'm going to use this to tag curtain wall mullions and transoms. Only in case the fields get very small this will be a problem, but then there's still the manual way to do this.

0 Likes

Thanks a lot! This set me on the right track and I got it working now. This line is basically what I was looking for:

Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)

 In the cases where I want to use this there won't be a problem with getting messy. I'm going to use this to tag curtain wall mullions and transoms. Only in case the fields get very small this will be a problem, but then there's still the manual way to do this.

Message 9 of 15
Jason.Rugg
in reply to: Michael.Navara

Jason.Rugg
Collaborator
Collaborator

@Michael.Navara You can absolutely remove a leader from a balloon. Place your normal balloon with a leader then right click and add a second vertex/leader, click the part again and attach the additional leader to the first leader line. Now you have a balloon with a leader that splits into two leaders, right click and delete leader and select the leader before it splits. Leader is gone, balloon is still attached to the drawing view/part and moves with the view/part. No need to create new styles or symbols.

0 Likes

@Michael.Navara You can absolutely remove a leader from a balloon. Place your normal balloon with a leader then right click and add a second vertex/leader, click the part again and attach the additional leader to the first leader line. Now you have a balloon with a leader that splits into two leaders, right click and delete leader and select the leader before it splits. Leader is gone, balloon is still attached to the drawing view/part and moves with the view/part. No need to create new styles or symbols.

Message 10 of 15
mat_hijs
in reply to: Jason.Rugg

mat_hijs
Collaborator
Collaborator

That actually sounds like a lot more work than creating a new style or a sketch symbol. And I might be wrong but that also sounds very hard or maybe even impossible to automate. I do appreciate the input though!

0 Likes

That actually sounds like a lot more work than creating a new style or a sketch symbol. And I might be wrong but that also sounds very hard or maybe even impossible to automate. I do appreciate the input though!

Message 11 of 15
Jason.Rugg
in reply to: mat_hijs

Jason.Rugg
Collaborator
Collaborator

@mat_hijs I would agree that yes it is more work if you have to do it a lot, I was mainly just pointing out to @Michael.Navara that you can actually delete a leader from a standard balloon. We have tried to automate this but haven't had much luck. 

0 Likes

@mat_hijs I would agree that yes it is more work if you have to do it a lot, I was mainly just pointing out to @Michael.Navara that you can actually delete a leader from a standard balloon. We have tried to automate this but haven't had much luck. 

Message 12 of 15
mat_hijs
in reply to: Jason.Rugg

mat_hijs
Collaborator
Collaborator

This would definitely be the solution if you wanted to do this for just a couple balloons.

0 Likes

This would definitely be the solution if you wanted to do this for just a couple balloons.

Message 13 of 15
mat_hijs
in reply to: mat_hijs

mat_hijs
Collaborator
Collaborator

@theo.bot I'm running into a problem now. The code works perfectly as long as the components you want to annotate are parts. But if you want to annotate subassemblies it'll just put the part number of one of the components since that's what's selected by the drawing curve. Do you have any way around this?

0 Likes

@theo.bot I'm running into a problem now. The code works perfectly as long as the components you want to annotate are parts. But if you want to annotate subassemblies it'll just put the part number of one of the components since that's what's selected by the drawing curve. Do you have any way around this?

Message 14 of 15
theo.bot
in reply to: mat_hijs

theo.bot
Collaborator
Collaborator

@mat_hijs 

 

The challenge is the definition of the sketched symbol, it gets the partnumber of the attached geometry. So an alternative way would be an sketched symbol with prompted entry, that you fill with the part number of the occurrence, the sub assembly.

I created a new sketched symbol with a prompted entry to test it, and it works.
But now if you use prompted entries you need to add some coding to update the symbols for any property updates in the model. 

 

Here's the sample that i used ( make sure you have a sketched symbol with only one prompted entry, to test this):

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

' Set a reference to Active sheet
Dim oSheet As Sheet 
oSheet = oDoc.ActiveSheet

' Set a reference to first Drawing view
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)

' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

'create a object collection for leader points
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition
Logger.Info(oMainAsm.DisplayName)
' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
Logger.Info(oOcc.Name)
		' Set a reference to the centerpoint of the model
		Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass
		Dim oOccPartNumber As String = oOcc.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value

		' Convert the centerpoint of the model to a point on the sheet
		Dim oPositionPoint As Point2d = oView.ModelToSheetSpace(oOccCenterPoint)

		If oView.DrawingCurves(oOcc).Count <> 0 Then

			oLeaderPoints.Clear

			' The found curve is a drawing curve segment so we need to get the drawing curve.
			Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)
			
			'Get the midpoint from the curve
			Dim oGI1 As GeometryIntent
			oGI1 = oDoc.ActiveSheet.CreateGeometryIntent(curve, kCenterPointIntent)

			oLeaderPoints.Add(oPositionPoint)
			oLeaderPoints.Add(oGI1)

			' Set a reference to the Sketch Symbol Definition
			Dim oSketchSymbolDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("PartNumberPrompt")
			Dim oPromptStrings As String() = {oOccPartNumber}

			' Place a Sketch Symbol
			Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, 0, 1,oPromptStrings)
			oSketchSymbol.Static = True
			oSketchSymbol.Leader.AddLeader(oLeaderPoints)
			oSketchSymbol.LeaderVisible = False
			oSketchSymbol.Name = oOcc.Name
		
		End If

Next

 

0 Likes

@mat_hijs 

 

The challenge is the definition of the sketched symbol, it gets the partnumber of the attached geometry. So an alternative way would be an sketched symbol with prompted entry, that you fill with the part number of the occurrence, the sub assembly.

I created a new sketched symbol with a prompted entry to test it, and it works.
But now if you use prompted entries you need to add some coding to update the symbols for any property updates in the model. 

 

Here's the sample that i used ( make sure you have a sketched symbol with only one prompted entry, to test this):

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

' Set a reference to Active sheet
Dim oSheet As Sheet 
oSheet = oDoc.ActiveSheet

' Set a reference to first Drawing view
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)

' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

'create a object collection for leader points
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

' Set a reference to the main assembly referenced by the Drawing View
Dim oMainAsm As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oMainAsmCompDef As AssemblyComponentDefinition = oMainAsm.ComponentDefinition
Logger.Info(oMainAsm.DisplayName)
' Loop through all top level occurrences in the main assembly
For i As Integer = 1 To oMainAsmCompDef.Occurrences.Count
	
	' Set a reference to the Component Occurrence
	Dim oOcc As ComponentOccurrence = oMainAsmCompDef.Occurrences.Item(i)
Logger.Info(oOcc.Name)
		' Set a reference to the centerpoint of the model
		Dim oOccCenterPoint As Point = oOcc.MassProperties.CenterOfMass
		Dim oOccPartNumber As String = oOcc.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value

		' Convert the centerpoint of the model to a point on the sheet
		Dim oPositionPoint As Point2d = oView.ModelToSheetSpace(oOccCenterPoint)

		If oView.DrawingCurves(oOcc).Count <> 0 Then

			oLeaderPoints.Clear

			' The found curve is a drawing curve segment so we need to get the drawing curve.
			Dim curve As DrawingCurve = oView.DrawingCurves(oOcc).Item(1)
			
			'Get the midpoint from the curve
			Dim oGI1 As GeometryIntent
			oGI1 = oDoc.ActiveSheet.CreateGeometryIntent(curve, kCenterPointIntent)

			oLeaderPoints.Add(oPositionPoint)
			oLeaderPoints.Add(oGI1)

			' Set a reference to the Sketch Symbol Definition
			Dim oSketchSymbolDef As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("PartNumberPrompt")
			Dim oPromptStrings As String() = {oOccPartNumber}

			' Place a Sketch Symbol
			Dim oSketchSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchSymbolDef, oPositionPoint, 0, 1,oPromptStrings)
			oSketchSymbol.Static = True
			oSketchSymbol.Leader.AddLeader(oLeaderPoints)
			oSketchSymbol.LeaderVisible = False
			oSketchSymbol.Name = oOcc.Name
		
		End If

Next

 

Message 15 of 15
mat_hijs
in reply to: theo.bot

mat_hijs
Collaborator
Collaborator

So if I understand correctly, this will be able to annotate everything correctly at first. But once everything is placed there is no link anymore? I don't really see a way yet to update the tags after they have been placed. Or more specific, updating the tags won't be a problem, but how will it know where it should get its information from when there is no link at all anymore?

I'm beginning to think that I might have to go back to either manually placing tags probably with AutoCAD blocks or to annotating everything in Revit.

0 Likes

So if I understand correctly, this will be able to annotate everything correctly at first. But once everything is placed there is no link anymore? I don't really see a way yet to update the tags after they have been placed. Or more specific, updating the tags won't be a problem, but how will it know where it should get its information from when there is no link at all anymore?

I'm beginning to think that I might have to go back to either manually placing tags probably with AutoCAD blocks or to annotating everything in Revit.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report