Hello All,
I am writhig a macro to put text ( count number) under each occurrence in an assembly.
I got the Sequence correct and able to place the cnumber un drawing sheet.
But What I need to do is to place that number under consequent occurrence.
Please find the Image file and you will see wht i am trying to get.
Any help will be highly appriciated.
i am icluding the Macro i written as well.
Private Sub RHSnumbering()
Dim oDrawingDoc As DrawingDocument
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then
Dim myVar1 As String
myVar1 = "Need to make a drawing the active document"
MsgBox Prompt:=myVar1, _
Title:="Drawing Document", _
Buttons:=vbExclamation
End
End If
Set oDrawingDoc = ThisApplication.ActiveDocument
Dim oView As DrawingView
If oDrawingDoc.ActiveSheet.DrawingViews.Count < 1 Then
Dim myVar2 As String
myVar2 = "Add a view to the drawing"
MsgBox Prompt:=myVar2, _
Title:="Views", _
Buttons:=vbExclamation
End
End If
Set oView = oDrawingDoc.ActiveSheet.DrawingViews(1)
Dim oDoc As Document
Set oDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oDoc.DocumentType <> kAssemblyDocumentObject Then
Dim myVar4 As String
myVar4 = "View's Referenced doc needs to be an assembly"
MsgBox Prompt:=myVar4, _
Title:="View Orientation", _
Buttons:=vbExclamation
End
End If
Dim oAssy As AssemblyDocument
Set oAssy = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oSketch As DrawingSketch
Dim sText As Integer
Dim oTG As TransientGeometry
Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawingDoc.ActiveSheet
Dim oGeneralNotes As GeneralNotes
Set oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
Dim oGeneralNote As GeneralNote
Dim Count As Integer
Dim oPoint As Point2d
Dim oOcc As ComponentOccurrence
Dim oOccDoc As Document
Dim oOccDocDef As AssemblyComponentDefinition
Count = 0
For Each oOcc In oAssy.ComponentDefinition.occurrences
If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
If InStr(oOcc.Name, "RHS") Then
Count = Count + 1
Set oTG = ThisApplication.TransientGeometry
Set oOccDoc = oOcc.Definition.Document
Set oOccDocDef = oOcc.Definition
' //////////////////////////////////////////////////////////////////////////////////
Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 3), Count)
' In Above statement I am trying to give center point of each occurrencess
' and to place the text at that point with the count
' Got the counting sequence right but poisitiong..... I am out of ideas.
'//////////////////////////////////////////////////////////////////////////////////////
On Error Resume Next
End If
End If
Next
oDrawingDoc.Update
End Sub
Solved! Go to Solution.
Solved by ADNpati. Go to Solution.
SOLVED IT.. AGAIN BY MYSELF...