Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to delete all parameters in a inventer file with ilogic

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
2104 Views, 5 Replies

how to delete all parameters in a inventer file with ilogic

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...... attaching file

 

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

 

 

5 REPLIES 5
Message 2 of 6
mrattray
in reply to: Anonymous

Why did you feel the need to post this three times?

Mike (not Matt) Rattray

Message 3 of 6
Anonymous
in reply to: mrattray

hey buddy

can you help me in that

if yes please

Message 4 of 6
Anonymous
in reply to: Anonymous

Thanks to all

still while you didn't help me

its ok

some how i found it it code to delete all unUsed parameters is........


Public Sub Main()    'ModelParameters()
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters
    On Error Resume Next
   Dim oPartDoc As Inventor.PartDocument  ' Obtain the active document, this assumes ' that a part document is active in Inventor.
   oPartDoc = ThisApplication.ActiveDocument

   Dim oParams As Parameters    ' Obtain the Parameters collection
   oParams = oPartDoc.ComponentDefinition.Parameters
i = MessageBox.Show("You wanna delete all Unused Parameters", "My iLogic Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If i=vbyees Then
   Dim iNumParams As Long      ' Iterate through the Parameters collection to obtain  ' information about the Parameters

   For iNumParams = oParams.Count To 1 Step -1                
       oParameter=oMyParameter(oParams.Item(iNumParams).Name).delete
   Next iNumParams
   End If
End Sub

Message 5 of 6
Anonymous
in reply to: Anonymous

I have this code its working

but need some work to be sharp

any help will be very thankful

 

Sub Main()
p = InputListBox("Choose to Delete", New String(){"None","All Rules","Features", _
"All unUsed Parameters","Everything in List"}, New String(){"None","All Rules","Features", _
"All unUsed Parameters","Everything in List"}, Title := "Chose to delete", ListName := "List")

Select Case p

Case "None"
'do nothing
Case "All Rules"
deleteRules()    
Case "Features"
deleteFeatures()
Case "All unUsed Parameters"
deleteParameters()
Case "Everything in List"
deleteRules()    
deleteFeatures()
deleteParameters()
End Select
End Sub

 Sub deleteRules()
Auto = iLogicVb.Automation
Dim iLogicAuto As Object
iLogicAuto = Auto
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

'Master file name

    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
    End Sub
    

 Sub deleteFeatures()
Auto = iLogicVb.Automation
Dim iLogicAuto As Object
iLogicAuto = Auto
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oFeatures As PartFeatures
    oFeatures = oDoc.ComponentDefinition.Features
    Dim oFeature As PartFeature
'Remove features
        For Each oFeature In oFeatures
            featureName = oFeature.Name
        
p = InputListBox("Choose to Delete", New String(){"None","All Features","Suppressed Features"} _
,New String(){"None","All Features","Suppressed Features"} , Title := "Chose to delete", ListName := "List")
'                If Not Feature.IsActive(featureName) Then
                If p="All Features" Then
                i = MessageBox.Show("Deleting All Features ")
                    oFeature.Delete
                Else If p="Suppressed Features" 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 Sub

            


Sub deleteParameters()
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters
    On Error Resume Next
   Dim oPartDoc As Inventor.PartDocument  ' Obtain the active document, this assumes ' that a part document is active in Inventor.
   oPartDoc = ThisApplication.ActiveDocument

   Dim oParams As Parameters    ' Obtain the Parameters collection
   oParams = oPartDoc.ComponentDefinition.Parameters
i = MessageBox.Show("You wanna delete all Unused Parameters", "My iLogic Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If i=vbyees Then
   Dim iNumParams As Long      ' Iterate through the Parameters collection to obtain  ' information about the Parameters

   For iNumParams = oParams.Count To 1 Step -1                
       oParameter=oMyParameter(oParams.Item(iNumParams).Name).delete
   Next iNumParams
   End If
End Sub


Message 6 of 6
Anonymous
in reply to: mrattray

hi, I am new to post here. i was just trying to post but after posting wasn't getting that it is post correctly or not. Sorry if it made any problem to anyone vicky

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

Post to forums  

Autodesk Design & Make Report