×
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

Drawing Link text to parameter with macro
2

Drawing Link text to parameter with macro

Drawing Link text to parameter with macro

(OP)
I have a drawing with several parameters created. Now I want to to create text notes in drawing linked to those parameters. I haven't found how to do it.

Any idea?

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

(OP)
I'm creating the macro to generate the title block and frame of my company. After all of this time working with CATIA, I never had much the need of doing 2D drawing. every time that I need to make some drawings I used a few templates that I have stored, and fill it by and. Now I'm doing something that I really need to make lots of drawings, then I need to do it properly, otherwise I will die fill the title blocks....

So what I have:

In the CATPart file I have a few parameters, that can be used in BOM and in title block of drawing.


In the CATDrawing, i create the need parameters to fill the title block


Now when I insert the title block of my company, I want that draws the entire frame and title block, and when creates the several texts of title block. I will also create a copy and past as a result with link, the desired parameters from the CATPart, after I want to create the attribute link to the parameter. Like this I want to have a link between the parameter and title block. If I change a parameter in the catpart the title block will update (at least it's what i'm expecting)


Please note: I create my drawing template like this, but I don't know if there is an easier way to do it. When I worked with solidworks in the past, I remember that when we insert the part file in the drawing, the drawing recognize all of parameters of the part, In CATIA i Haven't found how to do it.

Thanks




Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

It seems a little bit complicated....

You can avoid creating parameters in drawing, you can read the drawing source (part), get what parameters values you want, back in drawing, set parameters values for what text names you want.

Is true that you will have to run the macro each time you modify some parameters in part.... I don't know if you will find something about attribute link in documentation, I didn't check.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Drawing Link text to parameter with macro

(OP)
Found it :)


CODE -->

Dim relations1 As Relations
Set relations1 = DrwDocument.Relations

Dim parameters1 As Parameters
Set parameters1 = DrwDocument.Parameters

Dim strParam1 As StrParam
Set strParam1 = parameters1.Item("Teste")




 Set MyText1 = MyDrawingViews.ActiveView.Texts.Add((""), 100, 100)
     MyText1.TextProperties.Bold = 1
     MyText1.SetFontSize 0, 0, 2

MyText1.InsertVariable 0, 100, strParam1 


Now I need to make the next step... Link the parameters from CATPart to CATDrawing... Let's see if I can handle it.

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

(OP)
Yes definitely. Now I'm struggling with link the parameters from CATPart to catdrawing. I can do it manually but with macro looks difficult...

There is an way to manage the links of the catdrawing links. What I'm thinking. Manage a template manually create all the needed links, then use this template and then replace all links to the desired part. Is this doable? How can I manage the links via macro?

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

I create parameters in Catia user part properties. Then macro takes those parameters to a drawing. If this method is suitable for I'll upload a sample

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

(OP)
Yes I saw, but this don't create a link to the CATPart properties. I was looking for something that is permanently linked. If I change a parameter in CATPart the value updates in catdrawing.

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

2
This is how I get part properties

CODE --> vb6

'----FILLING PART PROPERTIES----
On Error Resume Next
Dim ProductDrawn
Set ProductDrawn = DrwSheet.Views.Item(3).GenerativeBehavior.Document

'----DRAWING NUMBER----
Dim DrwNo As String
DrwNo = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString

Set MyTextDrwNo = MyDrawingViews.ActiveView.Texts.Add("DRAWING No.", 246.5, 14)
MyTextDrwNo.Name = "TitleBlock_Text_Title_8"
MyTextDrwNo.SetFontSize 0, 0, 2
MyTextDrwNo.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextDrwNo.AnchorPosition = catTopLeft
DrwTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString
If (DrwNo <> "") Then
Else
Set MyTextDrwNo = Texts.GetItem("TitleBlock_Text_Title_8")
VariableDrw = InputBox("DRW. No. NOT FOUND! PLEASE ENTER DRAWING NUMBER" & Chr(13) & _
                     " " & Chr(13) & _
                    "GO BACK TO PART PROPERTIES, FILL DRAWING NUMBER AND UPDATE TITLE BLOCK", "DRAWING NUMBER WARRING", "ENTER DRAWING NUMBER")
MyTextDrwNo.Text = VariableDrw
End If

'----DESCRIPTION----
Dim Descr As String
Descr = ProductDrawn.DescriptionRef
Set MyTextDescr = MyDrawingViews.ActiveView.Texts.Add("DESCRIPTION", 263.4, 22)
MyTextDescr.Name = "TitleBlock_Text_Title_2"
MyTextDescr.SetFontSize 0, 0, 3
MyTextDescr.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextDescr.AnchorPosition = catMiddleCenter

Set MyTextDescrColor = DrwTexts.GetItem("TitleBlock_Text_Title_2")
MyTextDescrColorCol = 97191431
MyTextDescrColor.TextProperties.Color = MyTextDescrColorCol
MyTextDescrColor.TextProperties.Update

DrwTexts.GetItem("TitleBlock_Text_Title_2").Text = ProductDrawn.DescriptionRef
If (Descr <> "") Then
Else
Set MyTextDescr = Texts.GetItem("TitleBlock_Text_Title_2")
VariableDeskr = InputBox("DESCRIPTION NOT FOUND! PLEASE ENTER DESCRIPTION" & Chr(13) & _
                     " " & Chr(13) & _
                    "GO BACK TO PART PROPERTIES, FILL DESCRIPTION AND UPDATE TITLE BLOCK", "DESCRIPTION WARRING", "ENTER DESCRIPTION")
MyTextDescr.Text = VariableDeskr
End If


'----FILE NAME----
Set MyTextFileName = MyDrawingViews.ActiveView.Texts.Add("XXXXXXX", 239.59, 8.88)
MyTextFileName.Name = "TitleBlock_Text_Title_7"
MyTextFileName.SetFontSize 0, 0, 1.3
MyTextFileName.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextFileName.AnchorPosition = catTopLeft
DrwTexts.GetItem("TitleBlock_Text_Title_7").Text = ProductDrawn.Parent.Name

'----PART NUMBER----
Set MyTextPartNo = MyDrawingViews.ActiveView.Texts.Add("XXXXXXX", 25, 199)
MyTextPartNo.Name = "TitleBlock_Text_EnoviaV5_Effectivity"
MyTextPartNo.SetFontSize 0, 0, 3
MyTextPartNo.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextPartNo.AnchorPosition = catMiddleLeft
DrwTexts.GetItem("TitleBlock_Text_EnoviaV5_Effectivity").Text = ProductDrawn.PartNumber

'----COLOR PART NUMBER----
Set MyTextPartNoColor = DrwTexts.GetItem("TitleBlock_Text_EnoviaV5_Effectivity")
MyTextPartNoCol = 67150130
MyTextPartNoColor.TextProperties.Color = MyTextPartNoCol
MyTextPartNoColor.TextProperties.Update

'----REVISION----
Dim Rev As String
Rev = ProductDrawn.Revision
Set MyTextRev = MyDrawingViews.ActiveView.Texts.Add("XXX", 287.605, 12.4)
MyTextRev.Name = "TitleBlock_Text_Title_1"
MyTextRev.SetFontSize 0, 0, 1.8
MyTextRev.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextRev.AnchorPosition = catTopCenter
DrwTexts.GetItem("TitleBlock_Text_Title_1").Text = ProductDrawn.Revision
If (Rev <> "") Then
Else
Set MyTextRev = Texts.GetItem("TitleBlock_Text_Title_1")
VariableRev = InputBox("REVISION NOT FOUND! PLEASE ENTER REVISION" & Chr(13) & _
                     " " & Chr(13) & _
                    "GO BACK TO PART PROPERTIES, FILL REVISION AND UPDATE TITLE BLOCK", "REVISION WARRING", "ENTER REVISION")
MyTextRev.Text = VariableRev
End If

'----MATERIAL----
Dim Material As String
Material = ProductDrawn.ReferenceProduct.UserRefProperties.Item("MATERIAL").ValueAsString

Set MyTextMaterial = MyDrawingViews.ActiveView.Texts.Add("ENTER MATERIAL", 18.181, 40.345)
MyTextMaterial.Name = "TitleBlock_Text_Title_Material"
MyTextMaterial.SetFontSize 0, 0, 2
MyTextMaterial.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextMaterial.AnchorPosition = catTopLeft

Set MyTextMaterialColor = DrwTexts.GetItem("TitleBlock_Text_Title_Material")
MyTextMaterialColorCol = 67150130
MyTextMaterialColor.TextProperties.Color = MyTextMaterialColorCol
MyTextMaterialColor.TextProperties.Update

DrwTexts.GetItem("TitleBlock_Text_Title_Material").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("MATERIAL").ValueAsString
If (Material <> "") Then
Else
Set MyTextMaterial = Texts.GetItem("TitleBlock_Text_Title_Material")
VariableMaterial = InputBox("MATERIAL NOT FOUND! PLEASE ENTER MATERIAL" & Chr(13) & _
                     " " & Chr(13) & _
                    "OR GO BACK TO PART PROPERTIES, FILL MATERIAL AND UPDATE TITLE BLOCK", "MATERIAL WARRING", "ENTER MATERIAL")
MyTextMaterial.Text = VariableMaterial
End If

'----THICKNESS----
Dim Thickness As String
Thickness = ProductDrawn.ReferenceProduct.UserRefProperties.Item("THICKNESS").ValueAsString

Set MyTextThickness = MyDrawingViews.ActiveView.Texts.Add("ENTER THICKNESS", 33.366, 36.863)
MyTextThickness.Name = "TitleBlock_Text_Title_Thickness"
MyTextThickness.SetFontSize 0, 0, 2
MyTextThickness.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextThickness.AnchorPosition = catTopLeft

Set MyTextThicknessColor = DrwTexts.GetItem("TitleBlock_Text_Title_Thickness")
MyTextThicknessColorCol = 67150130
MyTextThicknessColor.TextProperties.Color = MyTextThicknessColorCol
MyTextThicknessColor.TextProperties.Update

DrwTexts.GetItem("TitleBlock_Text_Title_Thickness").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("THICKNESS").ValueAsString
If (Thickness <> "") Then
Else
Set MyTextThickness = Texts.GetItem("TitleBlock_Text_Title_Thickness")
VariableThickness = InputBox("MATERIAL THICKNESS NOT FOUND! PLEASE ENTER MATERIAL THICKNESS" & Chr(13) & _
                     " " & Chr(13) & _
                    "OR GO BACK TO PART PROPERTIES, FILL MATERIAL THICKNESS AND UPDATE TITLE BLOCK", "MATERIAL THICKNESS WARRING", "ENTER MATERIAL THICKNESS")
MyTextThickness.Text = VariableThickness
End If

'----FILE FOR MANUFACTURING----
'Dim FileForMFG As String
FileForMFG = ProductDrawn.ReferenceProduct.UserRefProperties.Item("FILE FOR MANUFACTURING").ValueAsString

Set MyTextFileForMfg = MyDrawingViews.ActiveView.Texts.Add("ENTER FILE FOR MANUFACTURING", 31.18, 10.411)
MyTextFileForMfg.Name = "TitleBlock_Text_Title_FileForMfg"
MyTextFileForMfg.SetFontSize 0, 0, 2
MyTextFileForMfg.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextFileForMfg.AnchorPosition = catTopLeft

Set MyTextFileForMfgColor = DrwTexts.GetItem("TitleBlock_Text_Title_FileForMfg")
MyTextFileForMfgColorCol = 67150130
MyTextFileForMfgColor.TextProperties.Color = MyTextFileForMfgColorCol
MyTextFileForMfgsColor.TextProperties.Update

DrwTexts.GetItem("TitleBlock_Text_Title_FileForMfg").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("FILE FOR MANUFACTURING").ValueAsString
If (FileForMFG <> "") Then
Else
Set MyTextFileForMfg = Texts.GetItem("TitleBlock_Text_Title_FileForMfg")
VariableFileForMfg = InputBox("FILE FOR MANUFACTURING NOT FOUND! PLEASE ENTER FILE FOR MANUFACTURING" & Chr(13) & _
                     " " & Chr(13) & _
                    "OR GO BACK TO PART PROPERTIES, FILL FILE FOR MANUFACTURING AND UPDATE TITLE BLOCK", "FILE FOR MANUFACTURING WARRING", "ENTER FILE FOR MANUFACTURING")
MyTextFileForMfg.Text = VariableFileForMfg
End If 
To update drawing you have to run update

CODE --> vb6

Private Sub UpdateSheetBtn_Click()
UpdateSheetBtn.BorderStyle = 1
'----GET CATIA----
On Error Resume Next
    Set MyCATIA = GetObject(, "CATIA.Application")
    If Err.Number <> 0 Then
        Set MyCATIA = CreateObject("CATIA.Application")
        MyCATIA.Visible = True
    End If
    On Error GoTo 0
'----CHECK IF ACTIVE DOCUMENT IS A DRAWING DOCUMENT----
If Not (TypeName(MyCATIA.ActiveDocument) = "DrawingDocument") Then
        message = MsgBox("ACTIVE DOCUMENT IS NOT A DRAWING..." & Chr(13) & _
       "OR PRESS CREATE NEW DRAWING DOCUMENT BUTTON AND THEN PRESS CREATE TEXT AGAIN...", vbOKOnly + vbExclamation, "ACTIVE DOCUMENT IS NOT A DRAWING")
       Exit Sub
    End If
'----END---
Dim MyDrawingDoc As DrawingDocument
Set MyDrawingDoc = MyCATIA.ActiveDocument

Dim MyDrawingSheets As DrawingSheets
Set MyDrawingSheets = MyDrawingDoc.Sheets

Dim MyDrawingSheet As DrawingSheet
Set MyDrawingSheet = MyDrawingSheets.ActiveSheet

Dim MyDrawingViews As DrawingViews
Set MyDrawingViews = MyDrawingSheet.Views

Dim drwviews As DrawingViews  'make background view active
Set drwviews = MyDrawingSheet.Views
drwviews.Item("Background View").Activate

'----FRAME CREATION----
'----DECLARATIONS----
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 selection1    As Selection
Dim Texts         As DrawingTexts
Set DrwDocument = MyCATIA.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 Selection = DrwDocument.Selection

'----UPDATE SHEET NUMBERING----
Dim DView As DrawingView
Dim SheetCount As Integer
Dim currentSheet As Integer
Set DrawingDoc = MyCATIA.ActiveDocument
SheetCount = DrawingDoc.Sheets.Count

currentSheet = 1 'initialize sheet number
For Each DrwSheet In MyDrawingDoc.Sheets
UpdatePageNumber DrwSheet, currentSheet, SheetCount
currentSheet = currentSheet + 1
Next

'----UPDATE DRAWING NUMBER----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateDrw DrwSheet
Next

'----UPDATE REVISION----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateDrw DrwSheet
Next

'----UPDATE TITLE----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateDrw DrwSheet
Next

'----UPDATE FILE NAME----
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateFileName DrwSheet
Next

'----UPDATE MATERIAL----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateMaterial DrwSheet
Next

'----UPDATE MATERIAL THICKNESS----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateMaterialThickness DrwSheet
Next

'----UPDATE FILE FOR MANUFACTURING----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdateFileForMFG DrwSheet
Next

'----UPDATE PART NUMBER----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdatePartNo DrwSheet
Next

Set drwviews = MyDrawingSheet.Views
drwviews.Item(1).Activate
'TitleBlockUpdatedForm.Show
UpdateSheetBtn.BorderStyle = 0
message = MsgBox("TITLE BLOCK HAS BEEN UPDATED", vbSystemModal + vbOKOnly + vbInformation, "UPDATE TITLE BLOCK")
   
End Sub

Sub UpdateDrw(currentDrawingSheet As DrawingSheet)
'----GET CATIA----
On Error Resume Next
    Set MyCATIA = GetObject(, "CATIA.Application")
    If Err.Number <> 0 Then
        Set MyCATIA = CreateObject("CATIA.Application")
        MyCATIA.Visible = True
    End If
    On Error GoTo 0
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 selection1    As Selection
Dim Texts         As DrawingTexts
Set DrwDocument = MyCATIA.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 selection1 = DrwDocument.Selection
Dim ProductDrawn
Set ProductDrawn = DrwSheet.Views.Item(3).GenerativeBehavior.Document
Dim DrwNo As String
DrwNo = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString

Dim backgroundView As DrawingView
    Dim MyText As DrawingTexts
    'Dim MyText As DrawingText
    Set backgroundView = currentDrawingSheet.Views.Item("Background View")
    Set dTexts = backgroundView.Texts
    
    On Error GoTo CreateNewDrwNo
    Set MyText = dTexts.GetItem("TitleBlock_Text_Sheet_8")
    MyText.Text = TitleBlock_Text_Title_8
    Exit Sub
    
    On Error GoTo CreateNewRev
    Set MyText = dTexts.GetItem("TitleBlock_Text_Title_1")
    MyText.Text = TitleBlock_Text_Title_1
    Exit Sub
       
    On Error GoTo CreateNewTitle
    Set MyText = dTexts.GetItem("TitleBlock_Text_Sheet_2")
    MyText.Text = TitleBlock_Text_Title_2
    Exit Sub

CreateNewDrwNo:
    dTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString

CreateNewRev:
    dTexts.GetItem("TitleBlock_Text_Title_1").Text = ProductDrawn.Revision

CreateNewTitle:
    dTexts.GetItem("TitleBlock_Text_Title_2").Text = ProductDrawn.DescriptionRef
  
End Sub 

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

(OP)
Hello,

Jenia Ladkov Really interesting. At this moment I haven't CATIA with me.

Can you explain me what is this?

'----UPDATE PART NUMBER----
On Error Resume Next
For Each DrwSheet In MyDrawingDoc.Sheets
UpdatePartNo DrwSheet
Next

UpdatePartNo is a catia vba function or is something located in another sub? I don't know this function and the other ones similar to this. Sorry I really need to learn a lot.

I have found a way to do it. Still a lot a work to do. At this moment I'm reading the needed parameters to fill the title block. Updating I think it will be easy. But I would like to do it when we make the drawing update. Probably I will need to create a "Special command" to update the drawing, and at the same time updates the title block.

I still need to work around a revision table.... So much work to do with this, just for a frame and a title block.

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

(OP)
I found another setback. I need to add a table (that I found how) but I need that table each column has a specific width. How can I do that?

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

CODE --> CATScript

'X coordinate
    Dim dX As Integer
    dX = 10
   
    'Y coordinate
    Dim dY As Integer
    dY = 10
   
    'Number of Rows
    Dim dRows As Integer
    dRows = 10
   
    'Number of Columns
    Dim dColumns As Integer
    dColumns = 5
   
    'Row Height
    Dim RowHeight As Integer
    RowHeight = 4
   
    'Column Width
    Dim ColumnWidth As Integer
    ColumnWidth = 10
   
    Dim MyTables As DrawingTables
    Dim MyTable As DrawingTable
      
    Set MyTable = MyDrawingView.Tables.Add(dX, dY, dRows, dColumns, RowHeight, ColumnWidth) 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Drawing Link text to parameter with macro

UpdatePartNo DrwSheet another sub. I don't like to store part properties as parameters. It's a par property and not parameter.

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

(OP)
Thanks Jenia it is fair enough. You have had a lot of work with that one.

Ferdo tomorrow I will try to resize the table. Thanks

This macro is almost finished, still a few more things like the revision table. But I 'm loving the result. I see many people working with a pre set file where they locate the frame and title block for the several sizes of papers. This looks good, but when they need to change from an A4 to an A3 it is a hell of a work, or like happens to me when I draw a strip layout, we can have sometimes 3 meters of paper long, and with scales. Adjust the frame and title block was...

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

Regarding sheet size prior to title block creation you can read sheet property an then use
"if sheet size A4 then
Else if..." and so on. In current application I don't have one code for different formats, but this is what I'll do in new version. Have to convert and redesign VB6 application to WPF.

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

(OP)
Well finally i have the job done. At least for now. Many thanks to all you for the help.

How can I change the title of this thread to "Creation of title box and frame" it would be useful for other users.

I created a video with the final result. Hope you like it. :)

https://www.youtube.com/watch?v=rEDAD-BYLSc

Thanks again to all of you.

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

hi Tiago can you help me with this. i saw your youtube vid about the drawing template macro, and it will be very helpful for me. thanks :) have a great day.

regards,
ian

RE: Drawing Link text to parameter with macro

can i have a copy of your script and try to use some of your codes. ive been searching for script of inserting a drawing template in catia. i need a script that can update revision number, s/n, pages and the template itself.

RE: Drawing Link text to parameter with macro

oh i forgot and a script of linking textbox in a parameter.

RE: Drawing Link text to parameter with macro

(OP)
It will be easier for you if just pick the right thing. Macro is too long and easy to get lost.

So if you want to star with the frame, you will need to draw it.

Let me try to make your life a bit easier.

Here you can find the needed code to access everything you need in drawing, including switch to background

CODE -->

'Declarations

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 selection1 As Selection
Set selection1 = DrwDocument.Selection

Set DrwDocument = CATIA.ActiveDocument
For Each DrwSheet In DrwDocument.Sheets



Dim sheet As Integer
sheet = sheet + 1

DrwDocument.Sheets.Item(sheet).Activate

Set MyDrawingSheets = DrwDocument.Sheets
Set MyDrawingSheet = MyDrawingSheets.ActiveSheet
Set MyDrawingViews = MyDrawingSheet.Views

CATIA.StartCommand ("Sheet Background")

  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

Dim DrwViews As DrawingViews  'make background view active
Set DrwViews = MyDrawingSheet.Views

'Find the dimension of each sheet in these variables
 Dim Sheet_Width
 Dim Sheet_Height
    
    Sheet_Width = MyDrawingSheet.GetPaperWidth
    Sheet_Height = MyDrawingSheet.GetPaperHeight
'Here you can add the code to draw the lines, text, points... of the frame
Next 

To add a line

CODE -->

Set Line1 = Fact.CreateLine(Sheet_Width - 26, 20, Sheet_Width - 33, 22)
    selection1.Clear
    selection1.Add (Line1)
    CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 1, 1
    CATIA.ActiveDocument.Selection.Clear 

To insert a text

CODE -->

Set MyText1 = MyDrawingViews.ActiveView.Texts.Add(("±0,05"), 21, 20)
MyText1.Angle = 90
MyText1.SetFontSize 0, 0, 1.8 

Try to make the use of this, with this you can create a lot of things, I would say that you can create the complete frame.

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

Hi Gents,
Could I ask,
Is it possible to pull some of the contents of the part/product properties straight into a drawing without having to use parameters?
Say Part number, Revision & Description ?
Just wondering

cheers
Alan

RE: Drawing Link text to parameter with macro

(OP)
I would have that too.

At the moment i'm opening the part inserted in drawing, and then read all parameters, and after that write them in drawing...

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

Alan yes it is possible. See my post from June 21, 2017.

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

I've taken a look and the only post on the 21 June refers to " CATIA.StartCommand("Define Contextual Links"), and a send key with enter, to press the ok "
Don't really understand what that's doing.
I was playing with the idea of a few little scripts to copy some of the properties to clipboard to save me going back and forth to the part.
I tend to add 'Material Grade', 'Stock Size' & 'Mass' properties boxes to my parts when I model them.
This is the code I botched together from other bits of code to copy the part number. Cant get it to work properly as it copies the whole path :(

--------------------------------------------------------

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument

Dim drawingDocument1 'As Document

Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 'As DrawingSheets

Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 'As DrawingSheet

Set drawingSheet1 = drawingSheets1.ActiveSheet

Dim drawingViews1 'As DrawingViews

Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 'As DrawingView

Set drawingView1 = drawingViews1.ActiveView

drawingView1.Activate

Dim FullName

FullName = drawingView1.GenerativeBehavior.document.ReferenceProduct.Parent.FullName

strNewNumber = FullName

sString = strNewNumber

'--------------copy to clipboard -------------------------------------

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oWrite = oExec.stdIn

oWrite.WriteLine sString
oWrite.Close

End Sub

RE: Drawing Link text to parameter with macro

Hi again, cant find any macro about creating textbox and link it on a parameter.

RE: Drawing Link text to parameter with macro

What is your requirement? To get info out of user user properties?

Regards,
Jenia Ladkov

RE: Drawing Link text to parameter with macro

(OP)
Try this:


CODE -->

Set strParam4 = parameters1.CreateString("Data Aprovou", "")

Set MyText1 = MyDrawingViews.ActiveView.Texts.Add((""), 79.5, 56.5)
MyText1.WrappingWidth = 23
MyText1.SetFontSize 0, 0, 1.8
MyText1.InsertVariable 0, 100, strParam4 

Tiago Figueiredo
Tooling Engineer

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

RE: Drawing Link text to parameter with macro

Guys,
Could someone tell me how I get the revision info from the part properties box?
This is so I can copy it straight to clipboard and paste in a drawing without having to open the parent part.

cheers
alan

RE: Drawing Link text to parameter with macro

When you open a drawing does catia not load the part into memory?
I always thought it needed to do that to see if the part needed updating.
I could be totally wrong with that statement and probably am :(

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