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.
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
Without viewing your title block code is difficult to say something...where is created the title block, in which view? In sheet background ? What sheet ?
Where is the position of your new text ? Which coordinates ?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
Anyway, another macro to insert your text in this title block can be done but there is no image attached in the post.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
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
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK
RE: ADDING A LINK TO EXISTING TITLE BLOCK
i need just a file name
Texts.GetItem("TitleBlock_Text_Title_7").Text=ProductDrawn.Parent.FullName
RE: ADDING A LINK TO EXISTING TITLE BLOCK
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: ADDING A LINK TO EXISTING TITLE BLOCK