Question

Here is what I was told is the correct way to access Inventor's "Replace Component" command:

Component.Replace(OldNamePath, NewNamePath, False)

But I'm getting a syntax error. What is the correct syntax? I'm not seeing it in the Inventor VBA library...

OldNamePath and NewNamePath are from different modules that create the full path name.

The error I'm getting is the "Expected =" error...

Was it helpful?

Solution

"That's the syntax for iLogic I believe.

There's a ComponentOccurence.Replace available per the programming help file.

It also contains examples for adding a new occurence and manipulating existing occurences."

From the Autodesk Inventor Customization Forum.

Also... "Are you doing this from iLogic or a VBA macro. If you're doing it from iLogic the command is Component.Replace but the parameters are:

Component.Replace(componentName, newPath, False) with componentName being the name of the component in the assembly.

If you're doing it from a VBA macro you need to set the ComponentOccurrance object of the component you want to change.

Dim occ as ComponentOccurrance

Set occ = (the component occurrance object you want to replace)



//To replace

occ.Replace(newPath, False)"

And a third response:

"

Public Sub CReplace()

Dim oOccurrence As ComponentOccurrence
Set oOccurrence = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Item(1)
oOccurrence.Replace "<filename>", True


End Sub

"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top