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: 

trying to add specific text to custom sketch symbol

0 REPLIES 0
Reply
Message 1 of 1
pmC76A4
93 Views, 0 Replies

trying to add specific text to custom sketch symbol

Hi all

 

im trying to get a macro to work but its being stubborn (or i dont know enough coding)

 

the macro, as it is now, adds user input text from a form into a drawing. 

 

but since that not all of our drawings are the same scale and even orientation of the sheet i got the idear to use the sketch symbol since that is on the template of all drawings since we beforehand filled in manually 

 

but here is my problem, how do i make the macro find the sketch symbol and insert the user input text according to the position of the symbol?

 

i have attached a screenshot where i have marked where im trying to place the text, the code i have now does place the text there but as statet, if the layout differs it does not work

 

I have show the code below

 

(also this is my first post, so if i have done something the incorrect way, by all means tell me and also if you see redundant coding or errors do tell im learning as i try)

 

 

 

Function fileExists(fname) As Boolean
If Dir(fname) <> "" Then fileExists = True Else fileExists = False
End Function
Public Sub data()
'Print all sheets in drawing document

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MsgBox "This is NOT an assembly document!", vbExclamation
Exit Sub
End If

Dim oPrintMgr As PrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
If MsgBox("Using default printer """ & oPrintMgr.Printer & """ Do you want to continue?", vbYesNo + vbQuestion) = vbNo Then
Exit Sub
End If

Dim oDrgPrintMgr As DrawingPrintManager

MsgBox "Using printer " & oPrintMgr.Printer & ", Color, Best Fit, 11x17 paper, Landscape."

dirPath = Left(oAsmDoc.FullFileName, Len(oAsmDoc.FullFileName) - Len(oAsmDoc.DisplayName))

Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
numFiles = 0

Dim form As New UserForm1

form.Show

'Print assembly drawing
idwPathName = Left(oAsmDoc.FullDocumentName, Len(oAsmDoc.FullDocumentName) - 3) & "idw"
If fileExists(idwPathName) Then
numFiles = numFiles + 1
'If numFiles = 10 Then Exit Sub
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute

oDrawDoc.Activate
Set oDrawDoc = ThisApplication.ActiveDocument
Set oDrgPrintMgr = oDrawDoc.PrintManager

oDrgPrintMgr.AllColorsAsBlack = False
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then

Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawDoc.ActiveSheet

' Set a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
Set oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes

Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

' Create text using various overrides.
sText1 = form.TextBox1
Set oGeneralNote1 = oGeneralNotes.AddFitted(oTG.CreatePoint2d(5, 25.75), sText1)

sText = form.TextBox2
Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(8, 25.75), sText)


Dim oDrgDoc As DrawingDocument
Set oDrgDoc = ThisApplication.ActiveDocument

' Set the printer name
' comment this line to use default printer or assign another one

'Set the paper size , scale and orientation
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.PrintRange = kPrintAllSheets
oDrgPrintMgr.Orientation = kLandscapeOrientation
oDrgPrintMgr.SubmitPrint

oGeneralNote.Delete
oGeneralNote1.Delete

oDrawDoc.Close (True)
End If

For Each oRefDoc In oRefDocs
Dim oType As String
oType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
If oRefDoc.SubType = oType Then

Else
idwPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "idw"
If fileExists(idwPathName) Then
numFiles = numFiles + 1
'If numFiles = 10 Then Exit Sub
'Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute

oDrawDoc.Activate
Set oDrawDoc = ThisApplication.ActiveDocument
Set oDrgPrintMgr = oDrawDoc.PrintManager

oDrgPrintMgr.AllColorsAsBlack = False
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager

Dim ActiveDocument As Sheet
Set ActiveDocument = oDrawDoc.ActiveSheet

Set oTG = ThisApplication.TransientGeometry

Dim oGeneralNotes2 As GeneralNotes
Set oGeneralNotes2 = ActiveDocument.DrawingNotes.GeneralNotes
Dim oGeneralNotes3 As GeneralNotes
Set oGeneralNotes3 = ActiveDocument.DrawingNotes.GeneralNotes

Set oGeneralNote = oGeneralNotes2.AddFitted(oTG.CreatePoint2d(5, 25.75), sText1)

Set oGeneralNote = oGeneralNotes3.AddFitted(oTG.CreatePoint2d(8, 25.75), sText)
End If
' Printer setup, default printer
oPrintMgr.ColorMode = kPrintDefaultColorMode ' Set to default
oPrintMgr.NumberOfCopies = 1 ' Set to print one copies.
oPrintMgr.Orientation = kLandscapeOrientation ' Set to print using landscape orientation.
oPrintMgr.PaperSize = kPaperSizeTabloid 'Set the paper size.
oDrgPrintMgr.PrintRange = kPrintAllSheets
oPrintMgr.SubmitPrint ' Submit the print.
oDrawDoc.Close (True)
End If
Next
MsgBox "There are " & numFiles & " sent to printer."
End If

End Sub

 

0 REPLIES 0

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report