CATScript for title block- how to control line thickness?
CATScript for title block- how to control line thickness?
(OP)
Good day,
My name is Andžejus, I'm new to this forum and to Catia.
I was trying to make a customized frame and title block script.
And I can't find how to control line thickness.
Here is a code that draws line:
Function CreateLine( iX1 As Double, iY1 As Double, iX2 As Double, iY2 As Double, iName As String) As Curve2D
Set CreateLine = Fact.CreateLine( iX1, iY1, iX2, iY2)
CreateLine.Name = iName
End Function
What code do I need to add to define line thickness?
Or where to look for that kind of information?
My name is Andžejus, I'm new to this forum and to Catia.
I was trying to make a customized frame and title block script.
And I can't find how to control line thickness.
Here is a code that draws line:
Function CreateLine( iX1 As Double, iY1 As Double, iX2 As Double, iY2 As Double, iName As String) As Curve2D
Set CreateLine = Fact.CreateLine( iX1, iY1, iX2, iY2)
CreateLine.Name = iName
End Function
What code do I need to add to define line thickness?
Or where to look for that kind of information?





RE: CATScript for title block- how to control line thickness?
here's a code
CODE --> catscript
CreateTextAF Text_58,GetOH() + Col(1)-14.7 ,GetOV() +13 ,"TitleBlock_Text_DASH" ,catTopLeft,1.2 Text_59 = "BB=MS20426AD" CreateTextAF Text_59,GetOH() + Col(1)-29 ,GetOV() +4.8 ,"TitleBlock_Text_BB" ,catTopLeft,1.2 Text_60 = "BJ=MS20470AD" CreateTextAF Text_60,GetOH() + Col(1)-29 ,GetOV() +2.3 ,"TitleBlock_Text_BJ" ,catTopLeft,1.2 Select Case GetContext(): Case "DRW": call SelectAll("NAME=TitleBlock_Line_FAS4") Set visProperties4Thck = Selection.VisProperties call visProperties4Thck.SetRealWidth(1, 1) End Select Select Case GetContext(): Case "DRW": call SelectAll("NAME=TitleBlock_Line_FAS6") Set visProperties4Thck = Selection.VisProperties call visProperties4Thck.SetRealWidth(1, 1) End Selectcode may be vary it depends on in which way you create title block and what language you are using
RE: CATScript for title block- how to control line thickness?
your code does what I wanted to achieve.
RE: CATScript for title block- how to control line thickness?
Here is code that puts a picture with logo on the drawing sheet:
Dim MySheet As DrawingSheet
'Set MySheet = CATIA.ActiveDocument.Sheets.ActiveSheet
Set MySheet = CATIA.ActiveEditor.ActiveObject.Sheets.ActiveSheet
Dim MyView As DrawingView
Set MyView = MySheet.Views.ActiveView
Dim MyDrawingPicture1 As DrawingPicture
Set MyDrawingPicture1 = MyView.Pictures.Add("M:\path_to_pisture_file.jpg", x_coordinate, y_coordinate)
I would like to put this picture in the background, together with the rest of text and lines.
Is it possible to do it?
RE: CATScript for title block- how to control line thickness?
my code almost the same
CODE --> catscript
Dim MySheet As DrawingSheet Set MySheet = CATIA.ActiveDocument.Sheets.ActiveSheet Dim MyView As DrawingView Set MyView = MySheet.Views.ActiveView Dim MyDrawingPicture1 As DrawingPicture Set MyDrawingPicture1 = MyView.Pictures.Add("C:\Program Files\Dassault Systemes\B24\win_b64\VBScript\FrameTitleBlock\TitleBlock_Picture_LOGOKanfit.bmp", 275., 29.)RE: CATScript for title block- how to control line thickness?
I really appreciate your support.
I tried your code, but it doesn't work for me. Here is error message it produces:
Source: Microsoft VBScript runtime error
Description: Object doesn't support this property or method:
'CATIA.ActiveDocument.Sheets'
Perhaps it is becouse of Catia version difference? I have V6.
My code (that I posted earlyer) works,
but it puts an image into the active view, and its XY position depends on active view's XY.
If there are no active views, picture is placed on active sheet, but not in the background.
And then there are some weird results with XY and scale of the picture- it works differently after I reload Catia.
Another thing I'm struggling with is title block text.
I want script to read property value from model and assign it to text.
I found out how to write a code that would assign new value to text,
But I dont know how to get that value from model.
I would appreciate any hints.
Do I need to create MeasureInertia, or can it be done without it?
I think volume is the most important- having it I could set script to calculate product weight.
RE: CATScript for title block- how to control line thickness?
try to work around on following
CODE --> catscript
If ProductDrawn <> Nothing Then Texts.GetItem("TitleBlock_Text_EnoviaV5_Effectivity").Text = ProductDrawn.PartNumber Texts.GetItem("TitleBlock_Text_Title_1").Text = ProductDrawn.Revision Texts.GetItem("TitleBlock_Text_Title_2").Text = ProductDrawn.DescriptionRef Texts.GetItem("TitleBlock_Text_Title_3").Text = ProductDrawn.Definition 'Texts.GetItem("TitleBlock_Text_Title_4").Text = ProductDrawn.Nomenclature Texts.GetItem("TitleBlock_Text_Title_5").Text = ProductDrawn.TITLE.ValueAsString Texts.GetItem("TitleBlock_Text_Title_FILE_FOR_MANUFACTURING").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("FILE FOR MANUFACTURING").ValueAsString Texts.GetItem("TitleBlock_Text_Title_7").Text = ProductDrawn.Parent.Name Texts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString MTRL =ProductDrawn.ReferenceProduct.UserRefProperties.Item("MATERIAL").ValueAsString Texts.GetItem("TitleBlock_Text_Title_9").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("MATERIAL").ValueAsString DrwSheets.Item(i).Views.Item(2).Texts.GetItem("TitleBlock_Text_Sheet_1_all").Text = CStr(nbSheet) Dim ProductAnalysis As Analyze Set ProductAnalysis = ProductDrawn.Analyze Texts.GetItem("TitleBlock_Text_Weight_1").Text = FormatNumber(ProductAnalysis.Mass,2) End Ifall the TitleBlock_Text created before. this exactly what you want. you get an item and then assign a parameter value to that item.
RE: CATScript for title block- how to control line thickness?
Will try to solve that later.
Regarding filling title block with model data- I'm getting into dead end too.
In the CATScript file for creating title block that was supplied together with Catia instalation
there is code that I believe retrieves model data:
'Dim ProductAnalysis As Analyze
'Set ProductAnalysis = ProductDrawn.Analyze
'Texts.GetItem("TitleBlock_Text_Weight_1").Text = FormatNumber(ProductAnalysis.Mass,2)
Its commented out. When I uncomment it it still doesn't work.
Then I was looking in V6 automation help, and found this code:
Set theInertiaService = CATIA.ActiveEditor.GetService("InertiaService")
Dim theInertiaElement As InertiaElement
Set theInertiaElement = theInertiaService.GetInertiaElement(theSelection)
Dim theVolume As Double
theVolume = theInertiaElement.GetVolume
Again, it doesnt work...
RE: CATScript for title block- how to control line thickness?
switch back to v5
RE: CATScript for title block- how to control line thickness?
Running macro to fill user added properties, I will check that out.
'Returning back' in my case would be switching to solidworks
RE: CATScript for title block- how to control line thickness?
Here's the code:
'insert Logo
set myLogo = View.Pictures.Add("M:\path\to\logo.jpg", Xposition, Yposition)
myLogo.height = 16.
myLogo.width = 60.
myLogo.Name = "TitleBlock_Logo"