Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone tell me where I'm going wrong

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274

Hi All,

I'm trying to fill some items on drawings using macro's with pop up boxes.
I've got most of it to work but it's in sheet background.
When I try to get it to alter some text on the working views I get an error 'Set DrwText = DrwTexts.GetItem("Text.222") 'TEXT NUMBER'
I am a bit stumped on how to work on the 'working views'

any help (as always) would be appreciated

Thanks

code below.

Sub CATMain()

CATIA.ActiveDocument.Selection.clear
Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection

Dim DrwDocument As Document
Dim drwsheets As DrawingSheets
Dim drwsheet As DrawingSheet
Dim drwviews As DrawingViews
Dim drwview As DrawingView
Dim DrwTexts As DrawingTexts
Dim DrwText as DrawingText
Set DrwDocument = CATIA.ActiveDocument
Set drwsheets = DrwDocument.Sheets
set drwsheet = drwsheets.item(1)
set drwviews = drwsheets.item(1).views
set drwview = drwviews.item(2)

Set DrwTexts = drwview.Texts

Dim oPART
oPART=InputBox ( "Enter Part number" ) 'pop up box
'oPART="XX/XXX/XX" 'for batch

Set DrwText = DrwTexts.GetItem("Text.221") 'SHEET No (this is on sheet background
DrwText.text = oPART

Set DrwText = DrwTexts.GetItem("Text.222") 'TEXT NUMBER (this is on the working views
DrwText.text = oPART
 
Replies continue below

Recommended for you

Document-> sheets-> views-> texts

set myTxtsView0 = drwsheet.views.Item(0).DrawingTexts
set myTxtsView1 = drwsheet.views.Item(1).DrawingTexts

like this you will be able to grab texts from view0 or view1

To get active view from active sheet texts:

set myActiveTxts = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.ActiveView.DrawingTexts (or something like this)

Eric N.
indocti discant et ament meminisse periti
 
Thanks itsmyjob

Could I ask would that go in the code please ?
Trying to get my head around how the call up for the drawing is layered.
ie. what each line is actually doing.
 
what are you trying to do?

yes the few lines I presented could be used in your code... with some correction i guess...
I am just trying to show you the way you can get drawingtext collection from views, you do what you want with it.

Please find the v5automation.chm file on your installation path and get familiar with CATIA APIs.

Eric N.
indocti discant et ament meminisse periti
 

Found the v5automation.chm and found a copy of 'VB Scripting for CATIA V5 4th Edition' that I got years ago.
Hopefully I'll get my head around some of this eventually.

Thought id try something simplpe like renaming the Text.object numbers.
Thats not goiung well either.

Hats off to anyone who has a grasp of this stuff lol
 
the Name of the text is the name the object text does have. the Text is the the value of the text you see on the drawing.

you might have

set myTxt = drawingtexts.item(3)

and myTxt.Name = "text.3" (the name of the text object) and also myTxt.Text="Hello world" (what you see on the drawing)

so changing values:

changing the value of the text in the drawing? you can do so with myTxt.Text = "Goodbye cruel world..."
changing the object name? you can do this myTxt.Name ="Text.007"


Eric N.
indocti discant et ament meminisse periti
 
Thanks itsmyjob,

Why can't they expliane it like that in the books :)

really appreciated

regards
Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor