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: 

Modify referenced model by iLogic

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
TONELLAL
6150 Views, 7 Replies

Modify referenced model by iLogic

Hello,

I try to modify on a drawing the 3d model, using iLogic (same thing as Inventor "Replace model reference" command). Do you know if it is possible ?

7 REPLIES 7
Message 2 of 8
TONELLAL
in reply to: TONELLAL

So... nobody need to replace the 3d model from a drawing ?

Message 3 of 8
xiaodong_liang
in reply to: TONELLAL

Hi,

 

This will need the Advanced API of iLogic: ThisDoc.Document.

 

 e.g. the code below replace the first file of the drawing to a new part. Hope it helps.

 

 doc = ThisDoc.Document
 Dim oFD As FileDescriptor
 oFD = doc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
 oFD.ReplaceReference("c:\NewPart.ipt")
 doc.Update()

 

Message 4 of 8
TONELLAL
in reply to: xiaodong_liang

Thanks !

This is exactly what I need !

Message 5 of 8
LOONYLEN
in reply to: xiaodong_liang

Xiaodong,

 

How would I change the following code to include a second .ipt in the replace reference routine?

I have a part 485000-001 and 485000-002. I can successfully replace the reference of the 485000-001 but, cannot replace the 485000-002.

 

Could you assist with this?

 

Sub SAVEDETAIL (ByVal TemplateDrawing As String, ByVal PLAINPN As String, ByVal PNWSUFFIX As String, ByVal PTASSYPN As String, ByVal filePath As String)

      DESTINATIONDOC = ThisApplication.DOCUMENTS.Open(TemplateDrawing, False)
      DESTINATIONDOC.SAVEAS(filePath & PLAINPN & ".idw", False)
      Dim STRNEWREFNAME As String
      Dim OREFFILE As FILEDESCRIPTOR

      For Each OREFFILE In DESTINATIONDOC.FILE.REFERENCEDFILEDESCRIPTORS
            Dim OORIGREFNAME As String
	   OORIGREFNAME = OREFFILE.FULLFILENAME
			
            If OORIGREFNAME.EndsWith(".ipt") Then           
		STRNEWREFNAME = filePath & PNWSUFFIX & ".ipt"            
		OREFFILE.REPLACEREFERENCE(STRNEWREFNAME)
				
	   ElseIf OORIGREFNAME.EndsWith(".iam") Then           
		STRNEWREFNAME = filePath & PTASSYPN & ".iam"            
		OREFFILE.REPLACEREFERENCE(STRNEWREFNAME)
				
	   End If
			
      Exit For
      Next
	  
      DESTINATIONDOC.Update()

      DESTINATIONDOC.Save
	  
      DESTINATIONDOC.Close
	  
End Sub

 

Senior Designer/Cad Administrator
Inventor 2012, w/SP2
Vault Collaboration 2012
Dell Precision T3500, Intel Xeon CPU
W3680 @3.33GHz, 16.0 GB of RAM
Microsoft Windows 7 Pro, 64 Bit Edition
Version 2009, w/SP1
Message 6 of 8
itults
in reply to: LOONYLEN

I am after some code that reads the .idw filename and uses the Replace Model Reference routine to replace the first component in the .idw with an .ipt or .iam that is in exactly the same folder.

Message 7 of 8
Pavel_JDK
in reply to: itults

Hi,

I was trying to make ilogic rule for changes of references. For Your request You can try function "idw reference" in enclosed rule "change_reference.iLogicVb". It's possible to run from model or drawing and it changes reference in idw file with same name model (ipt or iam or ipn) in the same folder. If there is second reference ipn model, it is also changed. 

You can use the rule also for changes of ipn, ipt and other references in many ways. 

Regards

Pavel

 

Here shoud be video. If not, You can see it on my dashboard...

https://autode.sk/2WfUKML

Message 8 of 8
Pavel_JDK
in reply to: Pavel_JDK

Another videos with example of using the rule change_reference:

https://autode.sk/30hbS5R
https://autode.sk/3fAanpH

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

Post to forums  

Autodesk Design & Make Report