×
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

CATScript for title block- how to control line thickness?

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?

RE: CATScript for title block- how to control line thickness?

i use title block creation function
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 Select 

code 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?

(OP)
Thank you, JeniaL,
your code does what I wanted to achieve.

RE: CATScript for title block- how to control line thickness?

(OP)
Now I stumbled upon another problem that I can't solve by myself.
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?

i don't understand how you create titleblock. the code posted above is from titleblock macro. any way you ran this in the background.

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?

(OP)
Thank you JeniaL,
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?

you are welcome. i use v5 r25. i don't remember how to activate background view. i'n pretty sure if you google for this you'll find that easily.

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 If 

all 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?

(OP)
I give up for now with logo placement.
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?

do you get all other properties and user added properties? check in the installation folder for a sample macro. this may help you a lot.
switch back to v5pipe

RE: CATScript for title block- how to control line thickness?

(OP)
Yes, my code fills file name, date, sheet number, scale, user.
Running macro to fill user added properties, I will check that out.
'Returning back' in my case would be switching to solidworks smile

RE: CATScript for title block- how to control line thickness?

(OP)
With some help from good people I found out how to put logo into the background.
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"

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