Inventor General Discussion

Inventor General Discussion

Reply
Contributor
celesiob
Posts: 15
Registered: ‎02-15-2013
Message 1 of 6 (276 Views)
Accepted Solution

delete rule with internal macro vba?

276 Views, 5 Replies
11-08-2013 05:19 AM

good day,

someone from the forum knows the code to delete an internal rule of a document using a macro vba?

 

thank you in advance for now.

I found a solution to my problem, the following code deletes all the rules of the active document serves to cituação mine, but if anyone knows a way to delete a certain specific rule by name I would appreciate it.

 

Sub deleteRULE()

Dim i As Object
Set i = GetiLogicAddin(ThisApplication)

Dim oDoc As Inventor.Document
Set oDoc = ThisApplication.ActiveDocument

'' This will delete all rules in the document
Call i.DeleteAllRulesInDocument(oDoc)


End Sub

Function GetiLogicAddin(ByVal oApplication As Inventor.Application) As Object


Dim addIns As ApplicationAddIns
Set addIns = oApplication.ApplicationAddIns

Dim addIn As ApplicationAddIn


On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

 

If (addIn Is Nothing) Then
Set GetiLogicAddin = Nothing


Exit Function
End If

 

Call addIn.Activate

Set GetiLogicAddin = addIn.Automation


Exit Function


NotFound:


End Function

Distinguished Contributor
m.teleguz1
Posts: 193
Registered: ‎04-01-2013
Message 2 of 6 (256 Views)

Re: delete rule with internal macro vba?

11-08-2013 08:38 AM in reply to: celesiob

Why would you want to do that? Go to ilogic, rules, select the rule and delete.

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................
Privacy warning: Since I live in a country that has traded liberty for the illusion of security, all of your posts to me are being monitored and saved by the United States Government.


See My LinkedIn Profile
Distinguished Contributor
m.teleguz1
Posts: 193
Registered: ‎04-01-2013
Message 3 of 6 (250 Views)

Re: delete rule with internal macro vba?

11-08-2013 08:40 AM in reply to: celesiob

Check this post out.

 

http://forums.autodesk.com/t5/Inventor-Customization/Delete-iLogic-rule-using-VBA/td-p/3082010

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................
Privacy warning: Since I live in a country that has traded liberty for the illusion of security, all of your posts to me are being monitored and saved by the United States Government.


See My LinkedIn Profile
Contributor
celesiob
Posts: 15
Registered: ‎02-15-2013
Message 4 of 6 (244 Views)

Re: delete rule with internal macro vba?

11-08-2013 08:46 AM in reply to: m.teleguz1

the company where I am working on a customization was initially conducted using iLogic due to complessidade this need for customization and aperfessuar the same, we are migrating to vba, however constumização generates complito old with the new, due to existing internal parameters, and avoid this problem the best solution is to eliminate the old rule exists internally in the file, because all actions are performed through a form created in vba, I hope you consseguido justify my need.

Contributor
celesiob
Posts: 15
Registered: ‎02-15-2013
Message 5 of 6 (238 Views)

Re: delete rule with internal macro vba?

11-08-2013 08:50 AM in reply to: m.teleguz1

I've tried using this code but not watch out for my purpose, my goal is elimiar the existing rule only when necessary, such a solution is to delete all the rules in a specified folder. that is not what I precisso, already tried adptar the same for my situation and not got success.

Contributor
celesiob
Posts: 15
Registered: ‎02-15-2013
Message 6 of 6 (207 Views)

Re: delete rule with internal macro vba?

11-27-2013 10:58 AM in reply to: celesiob

I found a solution to my problem, the following code deletes all the rules of the active document serves to cituação mine, but if anyone knows a way to delete a certain specific rule by name I would appreciate it.

 

Sub deleteRULE()

Dim i As Object
Set i = GetiLogicAddin(ThisApplication)

Dim oDoc As Inventor.Document
Set oDoc = ThisApplication.ActiveDocument

'' This will delete all rules in the document
Call i.DeleteAllRulesInDocument(oDoc)


End Sub

Function GetiLogicAddin(ByVal oApplication As Inventor.Application) As Object


Dim addIns As ApplicationAddIns
Set addIns = oApplication.ApplicationAddIns

Dim addIn As ApplicationAddIn


On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

 

If (addIn Is Nothing) Then
Set GetiLogicAddin = Nothing


Exit Function
End If

 

Call addIn.Activate

Set GetiLogicAddin = addIn.Automation


Exit Function


NotFound:


End Function

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.