Hello Fellow Inventors!
My first post. New to iLogic (which is what I believe is the key to solve my request)
My company manufacturs many sheet metal parts that ends up being painted.
We need to describe both material and surface treatment in the title blocks on our idw's. Inventor parts then have a selected material (the required steel type) and a color override is applied (the required paint job)
But color override is not just like that to retrieve for the title block, like standard iproperties like <MATERIAL> or <THICKNESS>
See attached image for deeper understanding of my request for a solution.
How do I solve this issue? I believe it must be a well known issue for many companies..
Best Regards
Morten
Sub RetrieveColor() If ThisApplication.ActiveDocumentType <> Inventor.DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub Dim oDoc As Inventor.DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim oPropSets As Inventor.PropertySets Set oPropSets = oDoc.PropertySets Dim oPropSet As Inventor.PropertySet Set oPropSet = oPropSets.Item("Inventor Summary Information") Dim oProp As Inventor.Property Set oProp = oPropSet.Item("Comments") Dim oRefDoc As Inventor.Document Set oRefDoc = oDoc.ReferencedDocuments.Item(1) If oRefDoc.DocumentType <> Inventor.DocumentTypeEnum.kPartDocumentObject Then Exit Sub oProp.Value = oRefDoc.ActiveRenderStyle.Name End Sub
Hi Robert
Thank you for your reply!
I was under the impression that one was notified by mail, if a reply was made to ones post. I visited the forum to check - and YES a reply :o)
Well, I am trying your code. I get a bunch of errors I am trying to grasp. 'Let' and 'Set' sentences is not supported anymore
I use Inv 2012
Am I missing anything?
I try to look further on..
Best regards
Morten
Ok we're closing in:
Sub Main()
RetrieveColor()
End Sub
Public Sub RetrieveColor()
Dim oDoc As Inventor.Document
oDoc = ThisApplication.ActiveDocument
If Not ThisApplication.ActiveDocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Or ThisApplication.ActiveDocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oPropSets As Inventor.PropertySets
oPropSets = oDoc.PropertySets
Dim oPropSet As Inventor.PropertySet
oPropSet = oPropSets.Item("Inventor Summary Information")
Dim oProp As Inventor.Property
oProp = oPropSet.Item("Comments")
oProp.Value = oDoc.ActiveRenderStyle.Name
End Sub
I guess I didn't read your post correctly - somehow I missed that you were working in iLogic and that you were planning to run this with .ipts and .iams, not drawings.
The code I provided was to take the color overides from a referenced part and place it into the comments of the drawing. It was written in VBA.
If you wanted to go through an entire assembly you could use this code :
Dim openDoc As Inventor.Document Dim docFile As Inventor.Document openDoc = ThisDoc.Document If openDoc.DocumentType = kAssemblyDocumentObject Then For Each docFile In openDoc.AllReferencedDocuments iProperties.Value(docFile.DisplayName, _ "Summary", "Comments") = docFile.ActiveRenderStyle.Name Next End If
If you just wanted to do this for one part then something like -
iProperties.Value("Summary", "Comments") = _ ThisApplication.ActiveDocument.ActiveRenderStyle.Name
would work.
Hi Roger
Thanks a lot for all the great feedback - I will check your input asap and return with result!
Best regards
Morten