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: 

How do I get Color Override to iProperty? See attached

6 REPLIES 6
Reply
Message 1 of 7
mortenrisumhansen7822
833 Views, 6 Replies

How do I get Color Override to iProperty? See attached

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

6 REPLIES 6
Message 2 of 7

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

 

Message 3 of 7

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

Message 4 of 7

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
Message 5 of 7

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. 

Message 6 of 7
MegaJerk
in reply to: Robert..F

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. 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 7 of 7

Hi Roger

 

Thanks a lot for all the great feedback - I will check your input asap and return with result!

 

Best regards

 

Morten

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

Post to forums  

Autodesk Design & Make Report