Click here to Skip to main content
16,017,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm using Inventor iLogic to place a GeneralNote on a drawing if certain boxes aren't all filled out. There is a rule to identify this and it works and is set up in another rule, which activates this rule if there is a problem. These rules are triggered by the save button so unchecked drawing are watermarked and can't be made by the workshop.

How do I write another bit of code that identifies if the GeneralNote already exists on the drawing? I would like to create an 'if generalnote exists do not place another general note rule'.

VB
MessageBox.Show("This drawing has not been checked or approved. This message will be left as a watermark when document is saved.")
Dim oDrawDoc As DrawingDocument
 oDrawDoc = ThisApplication.ActiveDocument
'  a reference to the active sheet.
Dim oActiveSheet As Sheet
 oActiveSheet = oDrawDoc.ActiveSheet
'  a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
 oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
Dim oTG As TransientGeometry
 oTG = ThisApplication.TransientGeometry
 

Dim sText As String	
sText = "DRAFT COPY" & vbCrLf & "NOT FOR MANUFACTURE" & vbCrLf & "CRITICAL SECTIONS NOT FILLED OUT" 

Dim oGeneralNote As GeneralNote

oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(0.6, 6.5), sText) 'Bottom Left
oGeneralNote.TextStyle.FontSize = 0.5


What I have tried:

I have looked in the model tree and the GeneralNote doesn't exist in there, and even if it did I don't know what code I would write to do this. I have used google with no answers and ChatGPT is useless for iLogic problems.

Many thanks!
Posted
Comments
Dave Kreskowiak 23-Jan-24 11:16am    
Just a warning as your question is specific to using the Inventor SDK library and not VB/VBA/VB.NET. It is very unlikely you're going to get an answer to this. Your best bet would be to find a forum dedicated to the Inventor SDK. That is where you're going to find the highest concentration of users who know anything about the SDK.

About the best I can do is point you at the SDK documentation at https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-6FD7AA08-1E43-43FC-971B-5F20E56C8846
[no name] 23-Jan-24 12:24pm    
I expect "FontSize = 0.5" would make things microscopic. I've never gone below 6.
[no name] 24-Jan-24 4:15am    
by VB you can operate a better way for declaration of var, as the compiler guess the Type of the var when creating your .Exe

that makes :
Dim sText As String	
sText = "DRAFT COPY" & vbCrLf & "NOT FOR MANUFACTURE" & vbCrLf & "CRITICAL SECTIONS NOT FILLED OUT" 


becomes :
Dim sText = "DRAFT COPY" & vbCrLf & "NOT FOR MANUFACTURE" & vbCrLf & "CRITICAL SECTIONS NOT FILLED OUT" 


the Type of 'sText' will be "String" Type.
--------------
another good habit with Vars and Containers, and Objects too.
you have numberous objects in the first part of yourt code, so it's at same time memories slots occupied.
to put on a better 'memory management', you have the 'nothing' keyword working with Vars.

Dim oDrawDoc As DrawingDocument
 oDrawDoc = ThisApplication.ActiveDocument
'  a reference to the active sheet.
Dim oActiveSheet As Sheet
 oActiveSheet = oDrawDoc.ActiveSheet
'  a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
 oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
Dim oTG As TransientGeometry
 oTG = ThisApplication.TransientGeometry

// uses of all the vars and containers
// ....
// bottom of your code / function / sub

 oDrawDoc = nothing

 oActiveSheet = nothing

 oGeneralNotes = nothing
 
 oTG = nothing

'Nothing' is equal to 'free()' functions in C and pals.
it empties the memory , once you have a large/big object, or vars.
It's part of 'managed memories' and it's so accurate.
Andre Oosthuizen 24-Jan-24 14:13pm    
@Gerry, should be posted as a solution, covered in detail based on information given...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900