Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

ilogic rule to change iproperties ipt part without opening file

Anonymous

ilogic rule to change iproperties ipt part without opening file

Anonymous
Not applicable

Dear all

 

Anyone can help me .

I would like create a rule who call  external rule to change iproperties in a ipt file without opening ipt.

Is there a command line like  "auto.RunExternalRule(....).

I try it without succes. 

anyone can explain any method.

 

Thank's very nice

 

 

PKZ

0 Likes
Reply
2,212 Views
14 Replies
Replies (14)

MechMachineMan
Advisor
Advisor

Hi.

 

You must use an external application (.exe, etc) that accesses the Apprentice Server if you wish to run a rule to change iProperties outside of inventor.

 

You could also just make a rule to run from a blank document in inventor that accesses Apprentice Server, or you can just access the files as deferred/invisible from within a rule in inventor.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

Anonymous
Not applicable

Thanks mechmachine for you answer.

 

is there not à way with  a rule like 

 

modelname = ThisDoc.ModelDocument.FullFileName 
namerule = "rulename.vb"
auto = iLogicVb.Automation
auto.RunExternalRule(modelname,"namerule")
 

Thanks for you help 

0 Likes

Anonymous
Not applicable

I forgot to say that i want to do this from a idw file and want to update the ipt composant

 

0 Likes

MechMachineMan
Advisor
Advisor

So you already have a rule in your .ipt that changes the iProperties to what you want?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

Anonymous
Not applicable

No in fact i want to call an external rule who change iproperties  in the .ipt from the .idw opened.

0 Likes

MechMachineMan
Advisor
Advisor
Do you already have this rule written? Or are you just wanting to make 2 rules to over complicate things?

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

Anonymous
Not applicable

yes i have already rules but i don't know how run it into a .ipt from .idw

 

thank's

 

0 Likes

MechMachineMan
Advisor
Advisor
k.

So to clarify some more, this pre-written rule is used in the ipt's by the user even when it isn't called by this new proposed rule?

Also, Is the intention to just run this rule from the idw, get the part document that corresponds with the idw, run the external rule, and only alter that single part?

Also, is it only ever supposed to alter 1 ipt at a time/ be run from the idw to only change iProperties in 1 file?

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

Anonymous
Not applicable

ok 

i frequently create .idw  part

 

i have to change iproperties in this .idw  but i also want to whange iproperties directly in the .ipt concerned like "iProperties.Value("project", "Creation Date" ) = Now" and others

it will be very usefull to me  not opening and closing each .ipt 1 

 

Thank you very nice for your help, i know that my english isn't very good but i also learn inthe end. :slightly_smiling_face:

Spoiler
 

 

0 Likes

MechMachineMan
Advisor
Advisor

Here is a sub routine I made that can accomplish what you want with minor modifications. I left in the proper way to change iProps in case you ever need it. You should only need to change things in ChangeIDWiProps Sub amd the ChangeModeliProps Sub.

 

You shouldn't need to uncomment anything to get it working for you; just simply replace with the name of your external rule. HOWEVER, you SHOULD change your iProperty format in your external rule because simply using iProperties.Value("Project", ....) ONLY changes it for the active document, and will thus not work for running an external rule in a document that is not active (i.e.; it will just keep applying the changes inteded for the ipt to the idw). Good luck.

 

 

 

 

 

 

 

Sub Main()

Dim oDwgDoc As DrawingDocument
Try
	oDwgDoc = ThisApplication.ActiveDocument
Catch
	MsgBox("Use Drawing Document Instead")
	Exit Sub
End Try

Dim oSheet As Sheet = oDwgDoc.ActiveSheet
Dim oDrawingView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModelDoc As Document = ThisApplication.Documents.ItemByName(oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.FullFileName)

ChangeIDWiProps(oDwgDoc)
ChangeModeliProps(oModelDoc)

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ChangeIDWiProps(oDoc As DrawingDocument)

'iLogicVb.Automation.RunExternalRule([DOCUMENT OBJECT], [RULE NAME])
iLogicVb.Automation.RunExternalRule(oDoc,"Sheet Name Formatting.txt")

'http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
'oDoc.PropertySets.Item("Inventor Summary Information").Item("Author").Value = ""
'oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ""
'oDoc.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = ""
'oDoc.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = ""

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub ChangeModeliProps(oDoc As Document)

'iLogicVb.Automation.RunExternalRule([DOCUMENT OBJECT], [RULE NAME])
iLogicVb.Automation.RunExternalRule(oDoc,"Sheet Name Formatting.txt")

'http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
'oDoc.PropertySets.Item("Inventor Summary Information").Item("Author").Value = ""
'oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = ""
'oDoc.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = ""
'oDoc.PropertySets.Item("Inventor User Defined Properties").Item("WO#").Value = ""

End Sub

 

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

bretrick30
Advocate
Advocate

I have an iLogic rule that kind of does what you are looking for.

 

This rule looks through my .idw sheets and finds the part/assembly I am looking for based off of the part number, in this example it is looking for an assembly that has a part number that begins with MF, MR, MS, MV, AR, AA, AW, AX, or AD.  What it is doing is changing the Designer of the model to match the current user.  Sometimes we have someone create the models and someone else create the drawings.

 

 

 

SyntaxEditor Code Snippet

oDoc = ThisDoc.Document
Dim oSheet As Sheet
Dim oSheets As Sheets
oSheets = oDoc.Sheets

Dim PNumCheck As String

For Each oSheet In oSheets
    Try
    RefDocProps = oSheet.DrawingViews.Item(1).ReferencedFile.DocumentDescriptor.ReferencedDocument.PropertySets
        
    PNumCheck = RefDocProps.Item("Design Tracking Properties").Item("Part Number").Expression
 
    Select Case Left(PNumCheck,2)
        Case "MF","MR","MS","MV","AR","AA","AW","AX","AD"
            RefDocProps.Item("Design Tracking Properties").Item("Designer").Expression = ThisApplication.Username
            
    End Select    

    Catch
        MessageBox.Show("Error: Finding assembly and overriding Designer." & vbNewLine & vbNewLine & oSheet.Name)
    End Try
    
Next

 

0 Likes

Anonymous
Not applicable

Thank's very nice MechMachineMan and bretrick30 for these answers.

I'll try to undersatnd the syntax of these rules and i'll return  you feed back soon.

 

best regards

PK

0 Likes

Anonymous
Not applicable

very well !

i try it , and it's very usefull for me.

i'll integrate it in my rules to easy change iproperties.

 

How can i check if some iproperties are not completed ?

 

 

Thank you very nice MechMachine

0 Likes

MechMachineMan
Advisor
Advisor

By using:

 

If iProp.Value is Nothing

 

If iProp.Value = ""

 

If iProp.Value.IsNullOrEmpty

 

 

All 3 of these work by just checking the contents of the String Type Variable and any one would work for this case. If they have writing in them, but its not what you want, you have to compare the format then.

 

Ie; if your part number is supposed to be like 123-4567 we could check for the format usingthe like operator from vb.net (google "vb.net msdn like operator" for more info)

 

iProp.Value Like "###-####"   ' # is a number wildcard; just means it's a digit, - is the symbol itself.

 

Or something simpler like:

 

iProp.Value Like "*-*"    '* is a wildcard when using the like operator; can be any char(number/letter/symbol) and any number of chars

 

(https://msdn.microsoft.com/en-us/library/swf8kaxw.aspx)


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type