Announcements
IMPORTANT. Forum to be archived in several phases. You can no longer submit new questions - but can only answer existing threads until Oct 17th 2016. Please read this message for details
Mechanical Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA External Component Definitions

3 REPLIES 3
Reply
Message 1 of 4
pdriley
173 Views, 3 Replies

VBA External Component Definitions

I have a problem whenver I need to move assemblies around on our server drives. Each external reference path needs to be changed to reflect the new location for each component. This is very tedious. I have tried manipulating the ExternalPath property of the McadComponentDefinition object, however it appears to be read-only. Is ther a way to programmatically change the external reference path for a component definition?

Thanks,

Paul
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: pdriley

Have you tried using Project Paths? I have a program that helps setup and
maintain project paths, but I never got much feedback on it, and my workflow
seldom required me to move files to really test it fully.

I think it is possible to repath the definitions in VBA, but I am not sure
how. A friend of mine started writing a program to do this a year or so
ago, and asked me to help. It was over my head with all the cycling that
was necessary to work up the assembly tree in the right order and all. I
wasn't much help, and shortly after that his company switched cad programs
so ???

I also know some people tried out this, but I have no knowledge of how it
works
http://www.simtel.net/pub/pd/17783.html

Good luck.

--
Kent Keller
Member of the Autodesk Discussion Forum Moderator Program

http://www.MyMcad.com/KWiK/Mcad.htm

"pdriley" wrote in message
news:f0ef04e.-1@WebX.maYIadrTaRb...
> I have a problem whenver I need to move assemblies around on our server
drives. Each external reference path needs to be changed to reflect the new
location for each component. This is very tedious. I have tried manipulating
the ExternalPath property of the McadComponentDefinition object, however it
appears to be read-only. Is ther a way to programmatically change the
external reference path for a component definition?
> Thanks,
>
> Paul
>
>
Message 3 of 4
pdriley
in reply to: pdriley

The code that follows works fine! The ExternalPath property IS read/write. Its just that when you query the object after changing the property, the object reports the old value. I came back to this assembly today and lo and behold all the external paths had been changed per my specification.

I tried the URL you suggested. It is knobbled shareware, but looks just OK. As you can see, the code that follows is simple and can be adapted to most situations.

Thanks for your help.

Paul


Sub RemapPath()
Dim Definitions As McadComponentDefinitions
Dim Definition As McadComponentDefinition
Dim mcad As McadApplication
Dim String1="X:\"
Dim String2="M:\MDT\SAXON\"

Set mcad = ThisDrawing.Application.GetInterfaceObject("Mcad.Application")
Set Definitions = mcad.ActiveDocument.AssemblyMgr.Definitions

For Each Definition In Definitions
'Check to see if String1 path is used.
If Definition.IsExternal And Left(Definition.ExternalPath, Len(String1)) = String1 Then
Definition.ExternalPath = String2 + Mid(Definition.ExternalPath, Len(String1)+1)
Debug.Print Definition.Name, Definition.ExternalPath
End If
Next
End Sub
Message 4 of 4
pdriley
in reply to: pdriley

Sorry, I fudged the "DIM XXX=" lines. You will need to declare String1 and String2 and assign separately.

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

Post to forums  

Autodesk Design & Make Report