Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Drawing Views to new CATPart

Status
Not open for further replies.

Lea75

Mechanical
Feb 24, 2009
51
ES
Hi guys, could someone tell me if it is possible to automate and how it would be the code for linking the views of a drawing to a new CATPart?

I have tried with this code but it does not work for me. I'm not sure if that property is read-only or I'm writing something wrong.

For j = 3 To odrawingviews.Count
Set odrawingviews.Item(j).GenerativeBehavior.Document.Parent.FullName = oPartDocument.FullName
Next j

Thank you in advance for any tip
 
Replies continue below

Recommended for you

should look into DrawingView.DrawingViewGenerativeLinks.AddLink

you can find that in the object map from CAAV5Automation.chm file ... in your [catia]Code\Bin folder

Eric N.
indocti discant et ament meminisse periti
 
Hi,
it is also important to delete existing links, so your code should look like the one below:

Code:
Option Explicit

Sub LinksReplace()
    Dim myDrawing As DrawingDocument
    Set myDrawing = CATIA.Documents.Item(1)
    
    Dim mySheet As DrawingSheet
    Set mySheet = myDrawing.Sheets.Item(1)
    
    Dim myPart As Document
    Set myPart = CATIA.Documents.Item(2)
    
    Dim i As Integer
    Dim currView As DrawingView, viewLinks As DrawingViewGenerativeLinks
    For i = 3 To mySheet.Views.Count
        Set currView = mySheet.Views.Item(i)
        Set viewLinks = currView.GenerativeLinks
        
        viewLinks.RemoveAllLinks
        viewLinks.AddLink myPart.Product
    Next
End Sub

Replace Documents indexes [CATIA.Documents.Item(x)] as you need in regards to your open documents and it should work.



Tesak
- Text along a curve for Catia V5
 
Thank you both. It works fine, but I have a problem.
It also loose links to dimensions
I have a stardard drawing (with all dimensions) linked to a stardard Part (that can change its shape) and it can be saved in different folders, so I need to point the drawing to different paths, but I can't loose the dimensions.
Is there any way to avoid it?
Regards
 
I don't think so. If you replace one part by another, links to dimensions are lost as well. You can however reconnect them with Re-route Dimensions command.

Tesak
- Text along a curve for Catia V5
 
If I do it manually I don't loose the dimension links.
CATParts are copies from the same original CATPart. Just change some dimensions among them.
 
You might get this behaviour using part templates. In the menu defining the part template you can instantiate also other documents (drawings of the part). However, i think you need 2 separate licences, PKT an KT1 if I remember correctly.

Best regards,
Costin Ruja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top