Changing derived part with ilogic

Changing derived part with ilogic

Anonymous
Not applicable
396 Views
3 Replies
Message 1 of 4

Changing derived part with ilogic

Anonymous
Not applicable

I'm trying to change which part my part is being derived from using this:

 

ThisApplication.ActiveDocument.File.ReferencedFileDescriptors.Item(1).ReplaceReference("FullFileNameAndExtension")

 ...but i keep getting the Error "the parameter is incorrect". I've checked my FullFileNameAndExtension is correct by using:

 

ThisApplication.Documents.Open("FullFileNameAndExtension", True)

 

... and this opens the new part fine.

 

I've also checked that the following is not nothing:

 

ThisApplication.ActiveDocument.File.ReferencedFileDescriptors.Item(1)

 

...and it is something! 

 

What am i doing wrong?

0 Likes
397 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous 

 

Is the new referenced file a copy of the old referenced file? 

 

I might be mistaken (its been a while) but I think you might get an error if you try to replace the "bolt with the battleship", but you can replace the "bolt with another bolt" or "battleship with another battleship"....

 

Maybe just something to rule out, or verify... but again I might be mis-remembering this, so hopefully I'm not creating confusion if I'm wrong 🙄

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 4

WCrihfield
Mentor
Mentor

Maybe you could try it this way.  It's more code, but if it works...

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oRefComps As ReferenceComponents = oDef.ReferenceComponents
For Each oRefComp As ReferenceComponent In oRefComps
	If oRefComp.Name = "Name Here" Then
		oRefComp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference("FullFileNameAndExtension")
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Or more accurately like this

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oDPComps As DerivedPartComponents = oDef.ReferenceComponents.DerivedPartComponents
For Each oDPComp As DerivedPartComponent In oDPComps
	If oDPComp.Name = "Name Here" Then
		oDPComp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference("FullFileNameAndExtension")
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes