Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Derived Part - Replace Model Reference

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
karthur1
13490 Views, 21 Replies

Derived Part - Replace Model Reference

We now finally have a way to change the part that is referenced in the idw using the "Replace Model Reference" command.  This first came out in the 2011 Subscription Adv Package and then it was included in Inventor 2012.  Before this tool the only way to change the referenced file was to munge the filename of the referenced file, then open the idw.  We then have th opportunity to select a different file.

 

In order to change the file that is referenced in a derived part, we have to go through the old mantra of munging the filename and opening the parent part.  Very time consuming.  What would be great if we had the ability to do a similar thing with derived parts. as we can now do with the idw.  If we had the ability to right-click on referenced file and chose "Replace Model Reference", that would be a great time saver.

 

2011-06-17_0808.png

21 REPLIES 21
Message 2 of 22
Daniela_Koloszko
in reply to: karthur1

You can post all the enhancement requests on our product feedback site , so that our development team takes into account your comments.

 

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1109794



Daniela Koloszko

Message 3 of 22
IgorMir
in reply to: Daniela_Koloszko

And why  is that your development team can not take that piece of request from here? After all it is in the company's best interest to listen to the customers requests and collect that information from whenever possible.

Or does this idea applies to small companies only?

Igor.

 


@Daniela_Koloszko wrote:

You can post all the enhancement requests on our product feedback site , so that our development team takes into account your comments.

 


 

Web: www.meqc.com.au
Message 4 of 22
Daniela_Koloszko
in reply to: karthur1

This is done in in order to have one site where all customers' comments and enhancement requests could be consolidated and followed up. It avoids also missing some of them.



Daniela Koloszko

Message 5 of 22
karthur1
in reply to: Daniela_Koloszko

Daniela,

I posted this here thinking that another user might know of a different way to accomplish this.  I have also sent in a request to the site that you mentioned above.

 

Thanks

Message 6 of 22
tmonty
in reply to: karthur1

Here is an iLogic rule that was written by Mike Deck from Autodesk (one of the Original iLogic Gurus) that will do what you are looking to do.  It looks for reference parts (derived parts) and then lets you browse for a replacement.  

We run it as an external rule that is fired from a Global form. That way you can run it from any file without having to include it in the file.  It has worked great for us.  Hope this helps.

 

Note - you will have to take the ".txt" extension off of the filename.  I was unable to post the file with the ".iLogicVb" extension.

Tags (1)
Message 7 of 22
Message 8 of 22
karthur1
in reply to: tmonty

SWEET Smiley Happy

 

Hopefully, that will be in a future release of Inventor.

 

Thanks

Message 9 of 22
israel.parker
in reply to: karthur1

I want to delete derived part using ilogic rule , do you know how to do it ?

Message 10 of 22
NWansink
in reply to: karthur1

So it's now been six years since you asked about this function.

Has anything changed? Has this function been added anywhere?

I've been looking, but can't find anything for it.

Replace Model Reference works so well in the .idw I can't understand how it hasn't been added in for derived parts yet.

I'm tired of having to close everything down to fudge the part names to make it work.

If we can use the function to Resolve Links, surely a function can be added to Replace Derived Reference.

Message 11 of 22
alex.haerens
in reply to: NWansink

It can all be that simple if you want it. In Solid Edge - for as long as I can remember (and that's long ! ) - you had a command on the old school application menu under "edit", reading "edit links". If you clicked on it you saw all the links that the file in question had with other files, be it drawing, part or assembly. You could click on anything and browse to a different file. After that the software did its best to comply. If it was on a drawing you got views of the new part. If it was an entirely new part then all your dimensions got detached, but you could guess that up front. If it was a derived part then every feature that could be recomputed on the new part would get recomputed.

 

Exactly what is happening with the present workarounds, without needing a workaround.

 

Alex

Message 12 of 22
karthur1
in reply to: alex.haerens

There is an IdeaStation post here for the Derived Part Replace Model Reference.

Message 13 of 22
petropnik
in reply to: karthur1

VBA.jpgQuiker way:

VBA:

STEP 1: Have the file open you want to change its reference

STEP 2: Open vba editor (ALT+F11)

STEP 3: Paste Code but first change filePath to match your new referenced file

STEP 4: Press F5 or the play button

STEP 5: Enjoy your success!!!:)

 

 

Public Sub Doit()
Dim odoc As PartDocument

Set odoc = ThisApplication.ActiveDocument
Dim ofile As File
Set ofile = odoc.File

Call ofile.ReferencedFileDescriptors.Item(1).ReplaceReference("E:\Personal Workspace\Designs\VARIOUS\VPR-215\215-001-016.ipt")

End Sub

 

 

 

SECOND WAY (NO CODE NEEDED):

STEP 1: PUT THE FILE WITH THE REFERENCE IN AN ASSEMBLY SAVE THE ASSEMBLY AND CLOSE ALL FILES

STEP 2: GO TO REFERENCED FILE AND RENAME IT IN FILE EXPLORER

STEP 3: OPEN THE ASSEMBLY THE FILE WILL OPEN WITH QUESTIONMARKS

STEP 4: USE SAVE AND REPLACE COMPONENT COMMAND

STEP 5: REPLACE REFERENCES YOU ARE DONE

Message 14 of 22
karthur1
in reply to: petropnik

Thanks for the suggestion.  The way that I do this is as follows:

  1. Save the code listed in post #6 above as an external iLogic rule.
  2. When I need to replace a model reference, I will run the code.  This give me the opportunity to replace the derived part.

 

Very quick and easy and you don't have to load, copy code each time to do it.  Give this a try and see if it works for you also.

 

Thanks,

Kirk

Message 15 of 22
aurel_e
in reply to: Curtis_Waguespack


@Curtis_Waguespack wrote:

 

An additional workaround:

http://inventortrenches.blogspot.com/2012/12/ilogic-replace-derived-reference.html

 

Hi,

is there any way to modify this rule for the files with more than one derived references. I would like to have a list of them and choose which to change.

Message 16 of 22

Hi @Curtis_Waguespack 

I've been using the Replace Derived Reference code from your blog with much success.

 

Now I'm trying to use part of the code to replace the derived reference file of a sub-component from an assembly rule.

 

For examples sake, I've already declared the sub-component as a variable called oSubDoc of type PartDocument.

I then took this part of the code & tweaked it to look at the sub-component:

Dim oRefFile As FileDescriptor
For
Each oRefFile In oSubDoc.File.ReferencedFileDescriptors oRefFile.ReplaceReference(NewDerivedFilePath) Next

The code runs without any error but the derived file is not getting replaced in the sub-component. Is it only possible to achieve this when the sub-component is the ActiveDocument?



Craig Henderson
Inventor Pro 2018.3.3, Build 284 / Vault Pro 2018 / Visual Studio 2012 / Excel 2013
Message 17 of 22
Manuelcamposcosta
in reply to: tmonty

Awesome ! thanks a lot!

Manuel Campos Costa
Message 18 of 22

Em C# encontrei uma solução simples, segue a mesma abaixo:

private void Processo()
{
// Obtém a aplicação do INVENTOR
Inventor.Application invpApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

// Obtém o documento de peça ativo
PartDocument partDocument = (PartDocument)invpApp.ActiveDocument;

// Obtém as definições do documento
PartComponentDefinition compDef = partDocument.ComponentDefinition;

// Obtém as peças referenciadas como derivadas
DerivedPartComponents devPartComp = compDef.ReferenceComponents.DerivedPartComponents;

// Obtém o primeiro item da lista de itens
DerivedPartComponent devComp = devPartComp[1];

// Nome completo do arquivo atual que esta sendo utilizado como referênvcia na peça derivada
string fileName = devComp.ReferencedFile.FullFileName;

// Nome do novo arquivo que está sendo utilizado nao peça derivada
string newFileName = @"C:\Users\User\Desktop\Testes\Copiar com Referencias\950.ipt";

// Altera a peça de referência
devComp.Replace(newFileName, null);
}

 

 

Observação:
Em anexo está uma imagem com a arvore do object brower para entendimento do código

Message 19 of 22

Codigo.PNG

object browser.PNG

  

Message 20 of 22

English please!

Google Translate:

 

In C# I found a simple solution, follow the same below:

private void Process()
{
// Get the INVENTOR application
Inventor.Application invpApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

// Get the active part document
PartDocument partDocument = (PartDocument)invpApp.ActiveDocument;

// Get document definitions
PartComponentDefinition compDef = partDocument.ComponentDefinition;

// Get the parts referenced as derived
DerivedPartComponents devPartComp = compDef.ReferenceComponents.DerivedPartComponents;

// Get the first item from the list of items
DerivedPartComponent devComp = devPartComp[1];

// Full name of the current file being referenced in the derived part
string fileName = devComp.ReferencedFile.FullFileName;

// Name of the new file being used in the derived part
string newFileName = @"C:\Users\User\Desktop\Testes\Copy with References\950.ipt";

// Change the reference part
devComp.Replace(newFileName, null);
}

Observation:
Attached is an image with the tree of the object brower for understanding the code

 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator

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

Post to forums  

Autodesk Design & Make Report