Modify referenced model by iLogic

Modify referenced model by iLogic

TONELLAL
Collaborator Collaborator
6,879 Views
7 Replies
Message 1 of 8

Modify referenced model by iLogic

TONELLAL
Collaborator
Collaborator

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 ?

0 Likes
Accepted solutions (1)
6,880 Views
7 Replies
Replies (7)
Message 2 of 8

TONELLAL
Collaborator
Collaborator

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

0 Likes
Message 3 of 8

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

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
Collaborator
Collaborator

Thanks !

This is exactly what I need !

0 Likes
Message 5 of 8

Anonymous
Not applicable

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

 

0 Likes
Message 6 of 8

Anonymous
Not applicable

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
Contributor
Contributor

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
Contributor
Contributor

Another videos with example of using the rule change_reference:

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