×
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

ADDING A LINK TO EXISTING TITLE BLOCK

ADDING A LINK TO EXISTING TITLE BLOCK

ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
Hi everyone,
I am needing help with adding a function to my titleblock that will generate text in a certain area when it is inserted in to my drawing. I want to add text that says "MODEL BASE: (.CATPart FILE NAME)". It would also be great if while generating the titleblock I could select whether or not to have the model base callout like you can with whether or not to have "PRELIMINARY" on the drawing. I am not sure how to do this given my lack of knowledge of how to edit a titleblock .CATscript file. this is something that is done to almost every drawing in the same location. Any help would be greatly appreciated.

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
I have attached the .catscript file of our title block. The title block is put in the sheet background. the "MODEL BASE: (.CATPART/.PRODUCT FILE NAME)" text only needs to be on sheet 1. you can see the position of the text in attached image file. the title block is proprietary to Harlow so please treat it as such.

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
text size is to be .079in

RE: ADDING A LINK TO EXISTING TITLE BLOCK

Bellow is an example how to add something in Background Sheet. You can adapt according to your needs.

CODE --> CATScript

Sub CATMain()

Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets

For i = 1 to DrwSheets.count
Set DrwSheet = DrwSheets.Item(i)
DrwSheet.Activate
Set DrwView = DrwSheet.Views.Item("Background View")
DrwView.Activate
Set DrwTexts = DrwView.Texts
Set Fact = DrwView.Factory2D

MsgBox "Text Will be created on: " & DrwSheet.name & " " & DrwView.name
Set Text = DrwTexts.Add("Test text",50,100)

MsgBox "Line Will be created on: " & DrwSheet.name & " " & DrwView.name
Set Line = Fact.CreateLine(50,100,100,100)

next
End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
From what I have figured out is that the CATscript has to be edited in a script editor not regular CATIA. I don't understand what you mean by "there is no image attached in the post."

RE: ADDING A LINK TO EXISTING TITLE BLOCK

Sorry, I just saw the doc file, stupid me smile

You can modify the code bellow in a normal text editor or Script Editor from CATIA...you can change myFontName or myFontSize or x,y position of the text - bellow is 100, 100 .

CODE --> CATScript

Sub CATMain()

Dim drawingTexts1 As DrawingTexts
Dim drawingText1 As DrawingText
Dim Text_string As String

Dim myFontSize As Double
myFontSize = "0.079"
Dim myFontName As Double
myFontName = "SSS1"


Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set DrwSheet = DrwSheets.Item(1)
DrwSheet.Activate
Set DrwView = DrwSheet.Views.Item("Background View")
DrwView.Activate

set drawingtexts1 = catia.activedocument.sheets.activesheet.views.activeview.texts

Text_string = "MODEL BASE: (.CATPART/.PRODUCT FILE NAME)" 

Set drawingText1 = drawingTexts1.Add(Text_string, 100, 100)
drawingText1.Text = Text_string

drawingText1.SetFontSize 0,0,myFontSize
drawingText1.SetFontName 0,0, myFontName

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
THIS QUESTION IS BECAUSE OF MY LAKE OF KNOWLEDGE OF SCRIPT READING AND WRITTING. WILL THIS PULL IN THE ACTUAL FILE NAME OF THE MODEL THAT THE DRAWING IS CONNECTED TO. SO FOR EXAMPLE THE FILE NAME OF THE MODEL IS 123ABC. WHEN I OPEN MY DRAWING AND INSERT THE TITLE BLOCK IN THE SHEET BACKGROUND IT WILL HAVE THE TEXT THAT SAYS MODEL BASE: 123ABC?

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
So I have added it to the end of the original script and changed the first line of myfontname to Monoscript821 BT. When I bring in the title block to a drawing it did not add the "MODEL BASE:" call out. What am I missing? What else do I need to do if anything? Sorry for all the questions, I just don't know anything about script writing.

RE: ADDING A LINK TO EXISTING TITLE BLOCK

Check the line

Set drawingText1 = drawingTexts1.Add(Text_string, 100, 100) - this is saying that the text will be written in 100, 100 coordinates of the background sheet. Modify 100, 100 according to your needs.

If you want to write the name of the linked 3D model there are different options:
1. InputBox - here the user can write himself the name of the file
2. Switching between CATIA windows and pick the desired one.
3. Using a code like this

Dim Name_of_3D
Name_of_3D = drawingView1.GenerativeBehavior.document.ReferenceProduct.Parent.Name

This has to be chosen depending if you use a PLM system or not.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
So the 100, 100 background coordinates, is that x direction = 100 and y direction = 100? I added #3 of your options above and still get nothing.sad

RE: ADDING A LINK TO EXISTING TITLE BLOCK

Run this CATScript separate to understand what is doing then you can "merge" with yours.

CODE --> CATScript

Sub CATMain()

    Exe = MsgBox("Please select a view from where you want to retrieve the model base name ", vbOK, "Retrieve the Pointed Document Name")

If Exe = vbCancel Then
Exit Sub
End If

Dim InputObject(0)
InputObject(0) = "DrawingView"

Dim DrwSelect As Selection
Set DrwSelect = CATIA.ActiveDocument.Selection

Status = DrwSelect.SelectElement2(InputObject, "Select View", False)
CATIA.StartCommand"Activate View"

Set drawingDocument1 = CATIA.ActiveDocument
Set Sheets = drawingDocument1.Sheets
Set activeSheet = Sheets.ActiveSheet
Set views = activeSheet.Views

	Dim sSel As Selection
    Set sSel = drawingDocument1.Selection
    sSel.Search "CATDrwSearch.DrwView,sel"
    Dim drwView                 As DrawingView
    Set drwView = sSel.Item(1).Value

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

Dim DocName
DocName  =  drawingView1.GenerativeBehavior.document.ReferenceProduct.Parent.Name

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim drawingTexts1 As DrawingTexts
Dim drawingText1 As DrawingText
Dim Text_string As String

Dim myFontSize As Double
myFontSize = "0.079"
Dim myFontName As Double
myFontName = "Monoscript821 BT"
Set DrwDocument = CATIA.ActiveDocument
Set DrwSheets = DrwDocument.Sheets
Set DrwSheet = DrwSheets.Item(1)
DrwSheet.Activate
Set DrwView = DrwSheet.Views.Item("Background View")
DrwView.Activate
set drawingtexts1 = catia.activedocument.sheets.activesheet.views.activeview.texts
Text_string = "MODEL BASE: " & DocName

On Error Resume Next
Set drawingText1 = drawingTexts1.Add(Text_string, 980, 85)
drawingText1.Text = Text_string

drawingText1.SetFontSize 0,0,myFontSize
drawingText1.SetFontName 0,0, myFontName

drawingSheet1.Views.Item(1).Activate

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: ADDING A LINK TO EXISTING TITLE BLOCK

(OP)
Works great by itself. haven't been able to get it to work in the title block script yet. I did get it positioned in the correct location and text size how I want it.

RE: ADDING A LINK TO EXISTING TITLE BLOCK

well i'm also wondering how to grab file name ind insert it on title block.following code works well but it gives me also a path to a file.
i need just a file name

Texts.GetItem("TitleBlock_Text_Title_7").Text=ProductDrawn.Parent.FullName

RE: ADDING A LINK TO EXISTING TITLE BLOCK

thanx Ferdo.

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