iLogic Pick function

iLogic Pick function

GosponZ
Collaborator Collaborator
3,840 Views
9 Replies
Message 1 of 10

iLogic Pick function

GosponZ
Collaborator
Collaborator

I do have this rule. Pick part in assembly run rule and fill iproperties. Is it there illogic rule that can pick face and then fill iproperties something like in this rule. Thank you

Sub Main()

   Dim oDoc As Document

   oDoc = ThisApplication.ActiveDocument

   Dim comps As SelectSet

   Dim comp As ComponentOccurrence

   comps = oDoc.SelectSet

   'If there are selected components we can do something, otherwise we're done

   If comps.count = 0 Then Exit Sub

   Dim aDoc As DocumentsEnumerator

   aDoc = oDoc.AllReferencedDocuments

   Dim iDoc As Document

   Dim cName As String

   Dim cTS As String

   Dim sTS As String

   Dim FNP As Long

   Dim cFNP As Long

   Dim docFN As String

   For Each iDoc In aDoc

     sTS = iDoc.FullFileName

     FNP = InStrRev(sTS, "\", - 1)

     docFN = Mid(sTS, FNP + 1, Len(sTS) - FNP)

     For Each comp In comps

         cTS = comp.Name

         cFNP = InStrRev(cTS, ":", - 1)

         cName = Left(cTS, cFNP - 1)

         If cName = Left(docFN, Len(docFN)-4) Then

           'Set iProperty in each of the selected parts in assembly

           iProperties.Value(docFN, "Custom", "MATERIAL") = "123"

           iProperties.Value(docFN, "Custom", "MATERIAL DESCRIPTION") = "SOME DESCRIPTION "

         End If

     Next

   Next

End Sub

0 Likes
Accepted solutions (1)
3,841 Views
9 Replies
Replies (9)
Message 2 of 10

JaneFan
Autodesk
Autodesk

Hello,

 

iLogic has pick funciton to pick with filter:

Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick(selectionfilterenum.kPartFaceFilter, "Select a face")

 

And with the selected face, we can get the relative Componentdefinition or document which the face belongs to:

oFace.Parent.ComponentDefinition

oFace.Parent.ComponentDefinition.Document




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 10

GosponZ
Collaborator
Collaborator

Hi Jane,

Thank you for your help.

What i trying to id  is to pick face and based on color of that face fill ipropertie for that face. Could you please guide me little bit more if possible.

Thanks for any input

0 Likes
Message 4 of 10

JaneFan
Autodesk
Autodesk

Hello MisterZS, 

 

The requirement is not clear to me. We can do something according to color of the selected face, but we can't set iProperties to a face since iProperties is part level instead of face or feature level. 

Do you want to set the iProperties of the containing occurrence of the selected face? 

 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 5 of 10

GosponZ
Collaborator
Collaborator

Hello Jane,

I do have parts that edge of those have specific color. Based on that color i would like to set custom iproperties for that edge on that part.

Something like if edge color is white then custom edge iprop = abc. 

Don't know if that is possible but if you guys programmers experts can help

 

Thank you

0 Likes
Message 6 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @GosponZ,

 

Instead of iPropeties, AttriubteSets might be useful to store data for edges. In the following article, Setting of AttributeSets are discussed.

 

http://adndevblog.typepad.com/manufacturing/2013/01/inventor-set-attributes-through-api.html

 

Please feel free to contact if there is any queries,

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 10

GosponZ
Collaborator
Collaborator

Thank you Chandra for  fast input.

To be honest never worked with attributes.

What i need is e.g. I do have cabinet door. On those 4 edges i  have to put edge band to cover raw edge. That narrow face (3/4") need to have custom ipropertie. One for code we using, and one for description of that code. Those 2 iprops i need to see in drawing.

I'm just looking faster way to fill out iproperties thru iam. in parts.

Thank you

0 Likes
Message 8 of 10

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @GosponZ,

 

On selecting face, respective ComponentOccurrence will be gathered and iProperties are added to the same ComponentOccurrence. Try the following iLogic code to perform the same.

 

Sub Main()

    Dim oFace As Face
    oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face")
    
    Dim occ As ComponentOccurrence
    occ = oFace.Parent.Parent    
    
    iProperties.Value(occ.Name, "Custom", "MATERIAL") = "123"
    iProperties.Value(occ.Name,  "Custom", "MATERIAL DESCRIPTION") = "Some description"
    
End Sub

Please feel free to contact if there is any queries,

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 9 of 10

GosponZ
Collaborator
Collaborator

Thank you Chandra it works perfect.

0 Likes
Message 10 of 10

tomislav.peran
Advocate
Advocate

Very nice! Thank you!

 

Face can be replaced with Edge in the code and than you can select an edge in the same way

0 Likes