Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need a way to Automate a change to an iProperty of multiple parts

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
SeanFarr
4051 Views, 15 Replies

Need a way to Automate a change to an iProperty of multiple parts

Hello,

 

Is there a way to change an iProperty, specifically the iProperties->Project->Project field for multiple parts automatically.

 

I use the iLogic Design Copy Tool to copy over an entire project, and for the most part the only changes is the project number.

 

I didn't see a way to change this in the Design Copy Tool, possibly there is some other tools that can do this that I don't know about. But if not, I am assuming a small script (VBA??) would be required to do this? whether it is in Inventor or just an outside program to carry out this change.

 

I found this old thread, but it seems that people just found another way to do this?

 

http://forums.autodesk.com/t5/Autodesk-Inventor/Use-iLogic-to-change-custom-iProperty-in-several-com...

 

 

My workflow would follow something like this:

-Use iLogic Design Copy Tool to copy over project to new folder

-Open up full assembly

-Run rule or script to update all parts in assembly with new Project iProperty

-Save

-update the drawings as I need, (they will all need to be reviewed as some parts will be modified anyways)

 

 

Any Ideas?

 

Thanks!

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
15 REPLIES 15
Message 2 of 16
jdkriek
in reply to: SeanFarr

Personally I'd use something like the iLogic code you linked, Design Assistant is horribly coded IMO.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 16
SeanFarr
in reply to: jdkriek

Hi Jonathan,

 

I have been playing around with iLogic(still in beginner mode). This is what I have come up with and it works perfectly, haha, however it only changes the Project iProperty for the top level assembly.

I need the rule to change the Project number through the entire assembly, meaning all the parts and the sub-assemblies and the parts within those sub-assemblies.

 

I hope this is possible, I'm sure it is, been digging around in these forums as well Curtis Waguespack's inventor trenches.

 

If you have any references for this, that would be great!

 

Thanks!

 

'used to trigger rule for testing or running the rule
Trigger = iTrigger0

'ignores errors and continues on with the code
On Error Resume Next

newprojectname= InputBox("Enter New Project Number Below", "New Project Number", newprojectname)
iProperties.Value("Project", "Project") = newprojectname

RuleParametersOutput()
iLogicVb.UpdateWhenDone = True

 

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 4 of 16
SeanFarr
in reply to: jdkriek

I managed to figure something out however the image below depicts how I feel:

 

programmermeme.jpg

 

Here is my adaptation of the code I linked to in the previous thread.

 

Dim openDoc As Inventor.Document
Dim docFile As Inventor.Document
Dim DrawingDoc As DrawingDocument
Dim FNamePos As Long
Dim docFName As String
Dim iDesc as String

DrawingDoc = openDoc
openDoc = ThisApplication.ActiveDocument
iDesc = iProperties.Value("Project", "Project")

newprojectname= InputBox("Enter New Project Number Below", "New Project Number", newprojectname)

For Each docFile In openDoc.AllReferencedDocuments

'change project iproperty for opened assmebly
iProperties.Value("Project", "Project") = newprojectname


'change project iproperty in all part files of opened assembly
	If docFile.DocumentType = kPartDocumentObject  Then
	
		FNamePos = InStrRev(docFile.FullFileName, "\", - 1)
		docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos)
		iProperties.Value(docFName, "Project", "Project") = newprojectname
	
	End If
'change project iproperty in all sub-assembly files of opened assembly
If docFile.DocumentType = kAssemblyDocumentObject   Then
		
		FNamePos = InStrRev(docFile.FullFileName, "\", - 1)
		docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos)
		iProperties.Value(docFName, "Project", "Project") = newprojectname
	
	End If

Next

iLogicVb.UpdateWhenDone = True

So what I got this to do was, to:

 

Prompt a message box for the user to input a new project number

Once it is entered, the opened assembly, all the parts inside that main assembly, all the parts inside the sub-assemblies and the sub-assemblies themselves have the Project iProperty filled.

 

I am understanding bit by bit, but I don't know what is going on in the first  9 lines, I know that it is declaring items or variables, but I can't for the life of me understand the logic behind this.

 

The next 4 lines make sense, as I added them, but this section here:

 

        FNamePos = InStrRev(docFile.FullFileName, "\", - 1)
        docFName = Mid(docFile.FullFileName, FNamePos + 1, Len(docFile.FullFileName) - FNamePos)
        iProperties.Value(docFName, "Project", "Project") = newprojectname

 

I have no idea what it is doing...

 

I am going to mark this thread solved eventually, but if anyone could explain these few short lines to me, it would be very awesome!!

 

Thanks!

 

EDIT:

 

This rule is ran in the main GA after project was copied to a new location using the iLogic Design Copy Tool.

I know that this means, for each project copied I will have duplciate file names, but that is why the Project code it critical as it defines which part belongs to which project incase of a mix up.

 

Now after running this rule, and updating the project iproperty in the part/assembly files, how would one update all the drawings so that the Project iProperty in the titleblock is updated. I was just going to do this manually, but if there is a way to do it, then I should probaly take advantage of the automation function.

 

Thanks again!!

 

 

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 5 of 16
jdkriek
in reply to: SeanFarr

Here you go 😃

 

This is adapted from Brian Ekins VBA code - I modified it for your purposes.

 

Paste it directly into a iLogic rule.

 

Sub Main() 
	'JDK 2013
	Dim oAsmDoc As AssemblyDocument = ThisDoc.Document

	' Get the project number from user
	ProjectNo = InputBox("Project Number", "Project", ProjectNo)
	
	' Change Project iProperty in Main Assemblhy
	iProperties.Value("Project", "Project") = ProjectNo
	
	' Call recursion function
	Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1, ProjectNo)
	Call oAsmDoc.Update
End Sub 
Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, _ 
Level As Integer, ProjectNo As String) 

Dim oOcc As ComponentOccurrence 
	For Each oOcc In Occurrences 

		'Change Project iProperty for all
		iProperties.Value(oOcc.Name, "Project", "Project") = ProjectNo
		
		' Check to see if this occurrence represents a subassembly 
		' and recursively call this function to traverse through it. 
		If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
			Call TraverseAssembly(oOcc.SubOccurrences, Level + 1, ProjectNo) 
		End If 
	Next 
End Sub
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 6 of 16
SeanFarr
in reply to: jdkriek

So this is to replace my hodgepodge rule to change all Project iProperties within the opened Assembly?

 

Thanks!

 

I have been digging around but found nothing yet; is it possible to update an iProperty field in a drawing without opening it?

 

I can't find nothing on this topic.

 

My next move is to develop a script that would:

  • Prompt user for a directory
  • open all the .idw's, update (the project iProperty would update because I would have ran the rule above to edit the parts/assemblies project iproperties beforehand),
  • save the .idw (export to pdf as well - this rule is already embedded into the .idw and exports automatically once save is applied)
  • then close that .idw, and proceed to the next .idw until all .idw's in that directory are updated.

I think this can be accomplished.

 

Thanks!

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 7 of 16
jdkriek
in reply to: SeanFarr

Have you looked into Apprentice for managing iProperties without Inventor?

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 8 of 16
SeanFarr
in reply to: jdkriek

Apprentice seems to be what I would require to change the iproperties of the Inventor files, however I think that I am in way over my head in regards to my current programming level. To be effectively use Inventor Customization, what specifically is the programming language VBA?

 

thanks for you help this far jdkriek!  it is all very helpful!!

 

 

 

 

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 9 of 16
jdkriek
in reply to: SeanFarr

Straight from Autodesk's API:


Keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production.

While I still have a ton of VBA macros out there, the plan is STILL to convert to VB.NET add-ins and external iLogic.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 10 of 16
SeanFarr
in reply to: jdkriek

OK, so one last question before I begin my quest into API Training:

 

What general steps would it take to edit iProperties of inventor files without opening them up? Not looking for specifics, just the general workflow.

 

Apprentice is not a program is how I interpreted it, you just use it gain access to Inventor file data by declaring it out in as an object?

 

Thanks!

 

 

 

Sean Farr
Product Designer at TESInc.ca

Inventor Professional 2014-Update 2 - AutoCAD Electrical 2014
Win7-x64 | ASUS P8Z77-V | i7 3770 -3.4 GHz | 32GB RAM |
240GB SSD | nVidia GTX 670 4GB - 320.49
Message 11 of 16
jdkriek
in reply to: SeanFarr

Program wise they all open to modify, but you can open invisible, so it's not showing the GUI but still opening the file.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 12 of 16
jcox150
in reply to: jdkriek

Is there a way to exclude changing specific (Standard) parts that wont share the project name?

Message 13 of 16
MaheshwarMD
in reply to: jdkriek

Hello,

 

Your code worked perfectly, even I am also looking for this solution.

Thanks a lot for a posting this code.

Mahesh
Message 14 of 16

Hi. If you are just changing an iProperty field, there is no need for iLogic.

Simply copy and paste the property in the Bill Of Materials from one part to another after you have made the property visible.

iLogic would only be useful for a large quantity of parts, or if you knew how to write the program in a reasonable amount of time.

--------------------------------------
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
Message 15 of 16
MechMachineMan
in reply to: SeanFarr

Also, the code given is a lot more complicated that it needs to be;

Simply have it update the property for all referenced files.

--------------------------------------
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
Message 16 of 16
marin
in reply to: jdkriek

Hi, I have been using this code for over 2 years, and it was very helpful. I have made iassembly with a members, and when I run the rule it changes project name of all parts, except members. Can you do a small change of line or two to make it work for members in iassembly also? Thx in front!!  

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

Post to forums  

Autodesk Design & Make Report