Inventor General Discussion

Inventor General Discussion

Reply
Contributor
hunkvicky.87
Posts: 13
Registered: ‎08-22-2012
Message 11 of 16 (404 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

08-22-2012 09:22 AM in reply to: jdkriek

Hi

I just made some changes in there as i needed and its working but one more thing i waana do is delete all parameters

either user parameters or model

 

Auto = iLogicVb.Automation
Dim iLogicAuto As Object
iLogicAuto = Auto
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

'Master file name
If Not (ThisDoc.FileName) = "iLogic" Then
    Dim ruleName As String
    Dim rules As Object
    rules = iLogicAuto.rules(oDoc)
    
    
        'Remove rules
        If Not (rules Is Nothing) Then
            For Each rule In rules
                ruleName = rule.Name
                iLogicAuto.DeleteRule(oDoc, ruleName)
            Next
            Else
            i = MessageBox.Show("No Rules are in File")
        End If
        
    Dim oFeatures As PartFeatures
    oFeatures = oDoc.ComponentDefinition.Features
    Dim oFeature As PartFeature

        'Remove suppressed features
        For Each oFeature In oFeatures
            featureName = oFeature.Name
            i = MessageBox.Show("Click Yes to delete all Fetures or No to Suppressed or Cancel to abort", "My iLogic Dialog", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)

'                If Not Feature.IsActive(featureName) Then
                If i=vbYes Then
                i = MessageBox.Show("Deleting All Features ")
                    oFeature.Delete
                Else If i=vbNo Then
'                i = MessageBox.Show("Deleting Supressed Features ")
                If Not Feature.IsActive(featureName) Then
                oFeature.Delete
                End If
            Else
                i = MessageBox.Show("Action canceled ")
                End If
        Next
End If

 

'but now something i wanna do is

 

'Remove all  Parameters too
     If Not (param Is Nothing) Then
     
         For Each param In params
          i = MessageBox.Show("Checking for Parameter in File")
        i = MessageBox.Show("No.of Parameters exists are ="& param.count)
         paramname=param.Name
         On Error Resume Next
         param.delete(oDoc, paramName)
               paramName =ThisDoc.Document.ComponentDefinition.Parameters
            iLogicAuto.Deleteparam(oDoc, paramName)
         Next
        Else
           i = MessageBox.Show("No Parameter are in File")

 

'Please help me in the I will be greatful

'Thanks and regards

"vicky

Contributor
hunkvicky.87
Posts: 13
Registered: ‎08-22-2012
Message 12 of 16 (403 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

08-22-2012 09:41 AM in reply to: jdkriek

hi dear sir/Buddy.................

 

A solution u did give earlier to some helped me alot what i wanna achive , Imade some chages according my need

and its working but i wanna little more help from u please......

 

Auto = iLogicVb.Automation
Dim iLogicAuto As Object
iLogicAuto = Auto
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

'Master file name
If Not (ThisDoc.FileName) = "iLogic" Then
    Dim ruleName As String
    Dim rules As Object
    rules = iLogicAuto.rules(oDoc)
    
    
        'Remove rules
        If Not (rules Is Nothing) Then
            For Each rule In rules
                ruleName = rule.Name
                iLogicAuto.DeleteRule(oDoc, ruleName)
            Next
            Else
            i = MessageBox.Show("No Rules are in File")
        End If
        
    Dim oFeatures As PartFeatures
    oFeatures = oDoc.ComponentDefinition.Features
    Dim oFeature As PartFeature

        'Remove suppressed features
        For Each oFeature In oFeatures
            featureName = oFeature.Name
            i = MessageBox.Show("Click Yes to delete all Fetures or No to Suppressed or Cancel to abort", "My iLogic Dialog", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)

'                If Not Feature.IsActive(featureName) Then
                If i=vbYes Then
                i = MessageBox.Show("Deleting All Features ")
                    oFeature.Delete
                Else If i=vbNo Then
'                i = MessageBox.Show("Deleting Supressed Features ")
                If Not Feature.IsActive(featureName) Then
                oFeature.Delete
                End If
            Else
                i = MessageBox.Show("Action canceled ")
                End If
        Next
End If

 

 

'but now something more i wanna do is...... delete parameters

 

        If Not (param Is Nothing) Then
        
            For Each param In params
            i = MessageBox.Show("Checking for Parameter in File")
            i = MessageBox.Show("No.of Parameters exists are ="& param.count)
            paramname=param.Name
            On Error Resume Next
            param.delete(oDoc, paramName)
                paramName =ThisDoc.Document.ComponentDefinition.Parameters
                iLogicAuto.Deleteparam(oDoc, paramName)
            Next
            Else
            i = MessageBox.Show("No Parameter are in File")
        End If

 'Regards

 'vicky

Distinguished Contributor
zdhrichard
Posts: 128
Registered: ‎05-03-2011
Message 13 of 16 (397 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

08-22-2012 11:20 AM in reply to: hunkvicky.87

Removing all  Parameters is what I wanna too.

 

Thanks lot for your contribution, Vicky.

 

I tested your code, but I do not know what is happened, code cannot get into "For .... Next" Loop.

 

That means:    "If Not (param Is Nothing) Then" gives me "False" although I have lot of parameters in my model. I could use "Delete All Rules and iLogic Parameters" to delete them. But the codes which you provided does not work.

 

Maybe it is because I am using Inventor 2009 if it is working in your side.

 

Any does anybody know how to delete suppressed components in *.iam by iLogic code?

 

Thank, anyhow.

Rich

Autodesk Inventor Professional 2014 (64 Bit Edition)
Build: 246, Release 2014 SP2 Update 2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
Active Member
kennethadelman
Posts: 6
Registered: ‎06-11-2014
Message 14 of 16 (132 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

06-11-2014 09:36 AM in reply to: jdkriek

Kriek,

 

That worked like a charm! And how would forms be deleted?

Active Contributor
bmerton
Posts: 26
Registered: ‎08-28-2014
Message 15 of 16 (65 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

10-07-2014 07:54 AM in reply to: jdkriek

Hi Jonathan,

 

This looks like exactly what I need but I can't get it to work.  I keep getting this error:

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartFeatures'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA33F1A5-7C3F-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

whenever I run this rule.  Do you have any ideas on what might be causing the problem?

 

Ben

Distinguished Contributor
zdhrichard
Posts: 128
Registered: ‎05-03-2011
Message 16 of 16 (42 Views)

Re: How to use iLogic Rule to delete rules and features in other parts?

10-08-2014 01:36 PM in reply to: bmerton

I do not know whether my issue is same with you but I do have similar error after I ran some rules in one model and open other model which includes rules.

What I do is before opening the new model, I close Inventor and re-start a new session. When I do this, I do not have the error.

 

It looks like some bugs in Inventor memory assignment.

 

Rich

Autodesk Inventor Professional 2014 (64 Bit Edition)
Build: 246, Release 2014 SP2 Update 2
Windows 7 Professional Service Pack 1
Intel(R) Xeon(R) CPU E5645
12.0 GB Memory
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!