APS swapping out models question

APS swapping out models question

Curtis_Waguespack
Consultant Consultant
379 Views
7 Replies
Message 1 of 8

APS swapping out models question

Curtis_Waguespack
Consultant
Consultant

Quick question about swapping out models with iLogic rules on APS (Autodesk Platform Services), for those of you that are more recent on this than myself.


with iLogic we can swap models out in 2 ways that I know of.

'use replace to swap the model
Component.Replace("MyPart:1", "Best Part Ever.ipt", True)
'use add to swap the model, will add the model if not present
Components.Add("MyPart:1", "Best Part Ever.ipt")


My understanding is that iLogic rule will find the model like this:

  1. It looks in memory for loaded models and if "Best Part Ever.ipt" is loaded, it uses that.
  2. If it doesn't find that model in memory, it looks under the *.ipj project file path for the model called "Best Part Ever.ipt"
  3. If the model is outside of the project path we can use the hard coded path "c:\temp\Best Part Ever.ipt"

If using APS, I think the 3rd option would not be an option for the environment.

 

Would someone be able to confirm for me that using the Replace and Add functions will work without issue in APS, by simply locating the model from memory or the *.ipj file?

Thanks in advance.

 

EESignature

0 Likes
380 Views
7 Replies
Replies (7)
Message 2 of 8

ryan.rittenhouse
Advocate
Advocate

It's been a minute since I've done this, but I did manage to find one of my APS test assemblies. We are doing both Add and Replace ops in it. I have a note in there from my past self saying that all files need to have "ThisDoc.Path" in front of it - relative paths do not work.

 

I can't promise that it's still the same (code is from a year and a half ago), but it looks like it works as you're going to need it to.

If this solved your problem, or answered your question, please click Accept Solution.
Message 3 of 8

Curtis_Waguespack
Consultant
Consultant

Thanks for the quick reply Ryan! You're a champ!

That is how I thought it worked as well, but I had this question come up, and wanted to confirm.

EESignature

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

I have not used APS, but I believe that at your 'step 2' stage mentioned above, it looks for that file within the same folder as the assembly, then maybe in its sub folders.  Not sure if it actually then jumps back up to 'project workspace' level and starts working its way back down or not, but that does sound like a logical next step after that one.  That's why putting ThisDoc.Path in front of it seems to work.  It is extremely rare for me to not specify full file path for assembly components, due to using single project file for most things, and it having a massive project workspace area.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 8

Curtis_Waguespack
Consultant
Consultant

Thanks @WCrihfield!

I did a little digging to see if could find this info documented, and...

The new iLogic API help is not as informative:
Inventor 2025 Help | ICadComponent.Replace Method | Autodesk
Inventor 2025 Help | IManagedComponents.Add Method | Autodesk

But the old help had this for component Replace

Some quick sanity checking showed that it seems to work the same for the Components.Add function.

Curtis_Waguespack_0-1746211199541.png

 

EESignature

Message 6 of 8

WCrihfield
Mentor
Mentor

Nice Link.  It would be great if they assigned someone who really knows this stuff inside & out to full time reviewing the online help documentation for Inventor's API & iLogic related stuff, and fixed all the existing Links, added additional Links, and provided more 'Samples' that utilize the 'iLogic' helpers, instead of just VBA' or one of the 'C#' type variations.  I have reported so many issues in the online help I can't keep track of all of them.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 8

Curtis_Waguespack
Consultant
Consultant

@WCrihfield, I just mentioned this exact thing to the Inventor dev team in survey.

I might have the opportunity to discuss this in a couple of weeks with them.

If so I'll volunteer you and Ryan for this. /jk 😁

 

 

EESignature

0 Likes
Message 8 of 8

JMGunner
Enthusiast
Enthusiast

@Curtis_Waguespack 

 

In APS  always have APSRule trigger thats set my search path for FactoryFilesPath

sometime i have use  ExternalRules

 

Best Regards JM Gunnar

 

If ThisApplication Is Nothing Then
'	        ' Check where MainAssembly is 
	        Dim folderAbove As String = System.IO.Path.GetDirectoryName(ThisDoc.Path) & "\"
	        Dim pathTovbFile As String = ThisDoc.Path & "\ExternalRules\"
	        Dim vbFileName As String = "iLogicUtils.iLogicVb"
	
	        
	        System.IO.File.Copy(pathTovbFile & vbFileName , folderAbove & vbFileName, True)
	        
	        iLogicVb.RunRule("MainRule")
	End If

 

 

 

 	If ThisApplication Is Nothing Then

                               SharedVariable("FactoryFilesPath") = ThisDoc.Path & "\Factory Files" 

                               SharedVariable("MemberFilesPath") = ThisDoc.Path &  "\Member Files"

                               SharedVariable("ProjektFilesPath") = ThisDoc.Path & "\Factory Files\Projekt"

                               SharedVariable("StandardComponents") = ThisDoc.Path & "\StandardComponents"

                               SharedVariable("Products") = ThisDoc.Path &  "\Factory Files\Products"

                               SharedVariable("TemplatePath") = ThisDoc.Path &  "\Factory Files"
							   
							   SharedVariable("TemplatePathDrawing") = ThisDoc.Path &  "\Factory Files\Drawings\"

               Else
				   			
							  SharedVariable("FactoryFilesPath") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Factory Files" 

                               SharedVariable("MemberFilesPath") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Member Files"

                               SharedVariable("ProjektFilesPath") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Factory Files\Projekt"

                               SharedVariable("StandardComponents") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Factory Files\StandardComponents"

                               SharedVariable("Products") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Factory Files\Products"

                               SharedVariable("TemplatePath") = "D:\VaultWorkingFolder\Designs\Balkong\Billy\Factory Files"
							   
							   SharedVariable("TemplatePathDrawing") = "D:\VaultWorkingFolder\Designs\Demo\Balkong\Factory Files\Drawings\"
				   

                              
               End If