×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Change drawing links
3

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?

Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Change drawing links

if you create a 3D template and a drawing linked to that 3D template, and if all 3D parts are made from the 3D template (or from a part made from the template) then you will be able to modify the link of the drawing to the 3D part. (the template here is just a regular part, it is just that you use it to make the other part using files save as, of file new from)

if you made your 3D part as new file then you wont be able to link your drawing to it.

Eric N.
indocti discant et ament meminisse periti

RE: Change drawing links

(OP)
It's my job,

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

(OP)
Ferdo Need your help.

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

(OP)
This is what I wrote.

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 Sub 

Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

RE: Change drawing links

2
(OP)
Found it. I was forgeting to put in addlink Product1.Product

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 Sub 


Tiago Figueiredo
Tooling Engineer

Youtube channel:
https://www.youtube.com/channel/UC1qdlBeJJEgMgpPLV...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources