Run ilogic external rule with Inventor VBA

Run ilogic external rule with Inventor VBA

Anonymous
Not applicable
888 Views
6 Replies
Message 1 of 7

Run ilogic external rule with Inventor VBA

Anonymous
Not applicable

can you please anyone who help me regarding following queries?

 

i  run rule in in inventor api for occurrences delete

 

i got these errors

 

Rule Compile Errors in Rule0, in occurrences.ipt

Error on Line 15 : 'For' must end with a matching 'Next'.

0 Likes
Accepted solutions (1)
889 Views
6 Replies
Replies (6)
Message 2 of 7

martin.jacko
Autodesk
Autodesk

Hi vinaykool,

 

Could you please provide rule text or dataset ?

From image I cannot find where is the problem.

 

Thanks,

Martin

0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks!! Martin

 

here is below the vba code

 

' Get the active assembly.
    Dim oIptDoc As PartDocument
    oIptDoc = ThisApplication.ActiveDocument

    ' Get the part component definition.
    Dim oIptDef As PartComponentDefinition
    oIptDef = oIptDoc.ComponentDefinition

    ' Get all of the leaf occurrences of the Part.
    Dim oLeafOccs As ComponentOccurrencesEnumerator
    oLeafOccs = oIptDef.Occurrences.AllLeafOccurrences

    ' Iterate through the occurrences and print the name.
    Dim oOcc As ComponentOccurrence

 
    'check for and skip virtual components
    
    If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then
            'set BOM as default if the component is visible
            If Component.Visible(oOcc.Name) = False Then
                doc = ThisDoc.Document
                Dim compOcc As ComponentOccurrence = Component.InventorComponent(oOcc.Name)
                compOcc.Delete()
    
            Else
            End If
    Else
    End If

0 Likes
Message 4 of 7

martin.jacko
Autodesk
Autodesk

Hi,

 

I tested code in Inventor 2018 and no error appears.

Which inventor version are you using ?

 

Thanks,

Martin

0 Likes
Message 5 of 7

Anonymous
Not applicable
Hello martin
I am using inventor _2017.
0 Likes
Message 6 of 7

martin.jacko
Autodesk
Autodesk
Accepted solution

Hi, could you please remove line

"'check for and skip virtual components"

 

and try again ?

 

Martin

0 Likes
Message 7 of 7

Anonymous
Not applicable
Thanks martin 
0 Likes