Hi Koemi,Koemi wrote:
here a small script with which you can replace entries of property "sourceFile" within A2 files.
Code: Select all
# -*- coding: utf-8 -*-
import FreeCADGui,FreeCAD
from PySide import QtGui, QtCore
import os, copy, time, sys, platform
OLD_CAD_FOLDER = "Z:\\blabla\\FreeCAD_files\\"
NEW_CAD_FOLDER = "D:\\raldiedal\\etc\\FreeCAD_files\\"
doc = FreeCAD.activeDocument()
count = 0
for obj in doc.Objects:
if hasattr(obj, 'sourceFile'):
if obj.sourceFile.startswith(OLD_CAD_FOLDER):
obj.sourceFile = obj.sourceFile.replace(OLD_CAD_FOLDER,NEW_CAD_FOLDER)
count += 1
print (
"{} names of sourcefile have been replaced\n".format(
count
)
)
1) Copy the macro to your macro folder
2) edit the macro and set your desired values of OLD_CAD_FOLDER and NEW_CAD_FOLDER
3) Save one of your bigger assemblies somewhere for testing
4) run the makro on this file being opened
5) please check, whether all sourceFile-names of imported parts are correctly set.
This test works only for one opened assembly, not for the subassemblies. You have to run this script again there.
What estimated number of assemblies do you have ?
Hint: you need \\ in path to get \