Change drawing links
Change drawing links
(OP)
I have a drawing with several views, that drawing corresponds to several similar parts. So I create a drawing that I create a template, and now I want to recreate those drawings.
What's the easiest way to do it?
Replace links one by one?
Any macro? Anyone have built something similar, how?
What's the easiest way to do it?
Replace links one by one?
Any macro? Anyone have built something similar, how?
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...





RE: Change drawing links
if you made your 3D part as new file then you wont be able to link your drawing to it.
indocti discant et ament meminisse periti
RE: Change drawing links
Did you checked TST?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Change drawing links
I have drawn all parts allready. It means that now I'm unable to relink the drawing?
Ferdo I haven't seen lately your tst. Do you have a tool to do it?
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Change drawing links
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Change drawing links
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
What should be in Product1?
I have tried the document file, and there is an error
DrwView.GenerativeLinks.AddLink Product1
I have tried open the file and use the value of Product1, and error again
Product1 = documents1.Open(strFilePath)
Can you help me?
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Change drawing links
CODE --> vba
Sub ReLink() Dim DrwDocument As DrawingDocument Dim DrwSheets As DrawingSheets Dim DrwSheet As DrawingSheet Dim DrwView As DrawingView Dim DrwTexts As DrawingTexts Dim Text As DrawingText Dim Fact As Factory2D Dim Point As Point2D Dim Line As Line2D Dim Cicle As Circle2D Dim Selection As Selection Dim GeomElems As GeometricElements Dim Part_name As String Dim Drawing_name As String Dim strFilePath As String Dim documents1 As Documents Dim partDocument1 As PartDocument Dim Product1 As ProductDocument Dim Number_View As Integer Dim windows1 As Windows Dim a As Integer Dim b As Integer Dim specsAndGeomWindow1 As SpecsAndGeomWindow Set documents1 = CATIA.Documents Set DrwDocument = CATIA.ActiveDocument Set DrwSheets = DrwDocument.Sheets Set Selection = DrwDocument.Selection Set DrwSheet = DrwSheets.ActiveSheet Set DrwView = DrwSheet.Views.ActiveView Set DrwTexts = DrwView.Texts Set Fact = DrwView.Factory2D Set GeomElems = DrwView.GeometricElements Set MyDrawingDoc = CATIA.ActiveDocument MyDrawingDoc.Sheets.Item(1).Activate Set windows1 = CATIA.Windows Drawing_name = CATIA.ActiveWindow.Name Number_View = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.Count If Number_View > 2 Then strFilePath = CATIA.FileSelectionBox("Select the CATPart or CATProduct, that you want to relink to this drawing", "*.*", CatFileSelectionModeOpen) If strFilePath = "" Then Exit Sub End If a = InStr(strFilePath, "CATProduct") b = InStr(strFilePath, "CATPart") If a > 0 Then Product1 = documents1.Open(strFilePath) End If If b > 0 Then Set partDocument1 = documents1.Open(strFilePath) End If Dim Num_Janelas As Integer Num_Janelas = windows1.Count Dim Janelas_array() ReDim Preserve Janelas_array(Num_Janelas) For i = 1 To Num_Janelas Janelas_array(i) = windows1.Item(i).Name If Janelas_array(i) = Drawing_name Then Set specsAndGeomWindow1 = windows1.Item(Janelas_array(i)) specsAndGeomWindow1.Activate End If Next For i = 3 To Number_View Set DrwView = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.Item(i) ' access links collection Dim oGenLinks As DrawingViewGenerativeLinks Dim linkedDocument DrwView.GenerativeLinks.RemoveAllLinks If a > 0 Then DrwView.GenerativeLinks.AddLink Product1 End If If b > 0 Then DrwView.GenerativeLinks.AddLink partDocument1 End If 'DrwView.GenerativeLinks.AddLink Next Else MsgBox ("There is no view to change links") End If End SubTiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
CODE --> vba
Sub ReLink() Dim DrwDocument As DrawingDocument Dim DrwSheets As drawingSheets Dim DrwSheet As drawingSheet Dim DrwView As DrawingView Dim DrwTexts As DrawingTexts Dim Text As DrawingText Dim Fact As Factory2D Dim Point As Point2D Dim Line As Line2D Dim Cicle As Circle2D Dim Selection As Selection Dim GeomElems As GeometricElements Dim Part_name As String Dim Part_name2 As String Dim Part_File As String Dim Drawing_name As String Dim strFilePath As String Dim documents1 As Documents Set documents1 = CATIA.Documents Dim partDocument1 As PartDocument Dim Product1 As ProductDocument Set DrwDocument = CATIA.ActiveDocument Set DrwSheets = DrwDocument.Sheets Set Selection = DrwDocument.Selection Set DrwSheet = DrwSheets.ActiveSheet Set DrwView = DrwSheet.Views.ActiveView Set DrwTexts = DrwView.Texts Set Fact = DrwView.Factory2D Set GeomElems = DrwView.GeometricElements Set MyDrawingDoc = CATIA.ActiveDocument MyDrawingDoc.Sheets.Item(1).Activate Dim Number_View As Integer Dim windows1 As Windows Set windows1 = CATIA.Windows Drawing_name = CATIA.ActiveWindow.Name Number_View = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.Count If Number_View > 2 Then 'Display file open dialog strFilePath = CATIA.FileSelectionBox("Escolha o ficheiro que pretende fazer o relink para este desenho", "*.*", CatFileSelectionModeOpen) If strFilePath = "" Then Exit Sub End If Dim a As Integer Dim b As Integer a = InStr(strFilePath, "CATProduct") b = InStr(strFilePath, "CATPart") If a > 0 Then Product1 = documents1.Open(strFilePath) End If If b > 0 Then Set partDocument1 = documents1.Open(strFilePath) End If Dim Num_Janelas As Integer Num_Janelas = windows1.Count Dim Janelas_array() ReDim Preserve Janelas_array(Num_Janelas) For i = 1 To Num_Janelas Janelas_array(i) = windows1.Item(i).Name If Janelas_array(i) = Drawing_name Then Dim specsAndGeomWindow1 As SpecsAndGeomWindow Set specsAndGeomWindow1 = windows1.Item(Janelas_array(i)) specsAndGeomWindow1.Activate Component_display = "Ok" End If Next For i = 3 To Number_View Set DrwView = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.Item(i) ' access links collection Dim oGenLinks As DrawingViewGenerativeLinks Dim linkedDocument DrwView.GenerativeLinks.RemoveAllLinks If a > 0 Then DrwView.GenerativeLinks.AddLink Product1.Product End If If b > 0 Then DrwView.GenerativeLinks.AddLink partDocument1.Product End If 'DrwView.GenerativeLinks.AddLink Next Else MsgBox ("Não existe nehuma vista, para trocar os links") End If End SubTiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...
RE: Change drawing links
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Change drawing links
Sometimes things got crazy
Tiago Figueiredo
Tooling Engineer
Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...