×
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

Titleblock macro to vb6

Titleblock macro to vb6

Titleblock macro to vb6

(OP)
trying to create vb version of titleblock ans stuck with setting up sheet format and getting part properties.
regarding to sheet format i need to set standard, sheet size and orientation. found same examples over the net but they don;t work.

also how do i get normal and added part properties?
this is not working

CODE --> vb6

Dim ProductDrawn
Set ProductDrawn = Nothing
Dim DrwNo As StrParam
Set DrwNo = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString
Set MyTextDrwNo = MyDrawingViews.ActiveView.Texts.Add("" & DrwNo, 247.45, 14)
MyTextDrwNo.Name = "TitleBlock_Text_Title_8"
MyTextDrwNo.SetFontSize 0, 0, 2
MyTextDrwNo.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextDrwNo.AnchorPosition = catTopLeft 


any help will be greatly appreciated.

cheers

RE: Titleblock macro to vb6

first you have

CODE -->

Set ProductDrawn = Nothing 

then you go

CODE -->

Set DrwNo = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString 

I am confused.. if ProductDrawn = Nothing how would you expect ProductDrawn.ReferenceProduct to give you anything?

Eric N.
indocti discant et ament meminisse periti

RE: Titleblock macro to vb6

(OP)
yea you are right about = nothing. just copied that from Catscipt. even if i remove this line nothing happens. i have a view in my drawing.

any ideas about sheet setting?

RE: Titleblock macro to vb6

(OP)
so i got how to get part properties using VB. still can't setup a page.

CODE --> vb6

Dim ProductDrawn As Product
Set ProductDrawn = DrwSheet.Views.Item(3).GenerativeBehavior.Document
Set MyText26 = MyDrawingViews.ActiveView.Texts.Add("DRAWING No.", 247.45, 14) 'MyText26.Name = "TitleBlock_Text_Title_8"
MyText26.Name = "TitleBlock_Text_Title_8"
MyText26.SetFontSize 0, 0, 2
MyText26.SetFontName 0, 0, "Century Gothic (TrueType)"
MyText26.AnchorPosition = catTopLeft
DrwTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString 

this code works well

RE: Titleblock macro to vb6

(OP)
well converting title block macro from CatScript going well except several things.
sheets numbering is driving me crazy
how do i get a current sheet number?

CODE --> vb6

currentSheet = DrwDocument.Sheets.Count 
this is counting total amount of sheets. yes i understand this is because of count command.

the second question how do i search for a text thru all the sheets in the drawing?
this is only works for a current/active sheet

CODE --> vb6

Selection.Search "CATDrwSearch.DrwText,TitleBlock_Text_Title_8_all"
DrwTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString 

RE: Titleblock macro to vb6


Current Sheet Number:

Create separate Function to get the SheetNumber

CODE

Function GetSheetNumberOf(ByVal oDrawingSheet As DrawingSheet, ByVal oDrawingSheets As DrawingSheets)
    GetSheetNumberOf = GetSheetNumberOf (oDrawingSheet.Name, oDrawingSheets )
End Function
Function GetSheetNumberOf(ByVal oDrawingSheetName As string, ByVal oDrawingSheets As DrawingSheets)
    Dim intSheetCounter As Integer = 0
    If (oDrawingSheet IsNot Nothing) Then
        For Each oCurSheet As DrawingSheet In oDrawingSheets
            intSheetCounter += 1
            If (oCurSheet.Name.Equals(oDrawingSheetName)) Then
                Exit For
            End If
        Next
    End If
    GetSheetNumberOf = intSheetCounter
End Function 

i hope Searching is like

CODE

Selection.Search "CATDrwSearch.DrwText.Name=*TitleBlock_Text_Title_8*, all" 
Not

CODE

Selection.Search "CATDrwSearch.DrwText,TitleBlock_Text_Title_8_all" 

Regards,
Maddy

RE: Titleblock macro to vb6

CODE

Selection.Search "CATDrwSearch.DrwText.Name=*TitleBlock_Text_Title_8*, all"
DrwText = selection.Item(1).Value
DrwText.Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString 

Regards,
Maddy

RE: Titleblock macro to vb6

(OP)
thanks. found the way how to get added properties.
function i will use later for title block update.

still got no luck with page setup. i can use catia page setup but in this way i lose the hole idea of my application.. i'm working on some drawing manager and moving all the actions from catscripts to the manager.
this will be something like this

RE: Titleblock macro to vb6

(OP)
well also got how to setup a standard and sheet size and sheet orientation however still having issues with a standard. there's no option for a custom standard.

how can i add custom standard? probably have to edit some library. is it possible?

now the heaviest section called revision block. in the well known sample title block macro this works pretty well with a lot of functions
inside CatScript. is there a simplest way to create revisions block? revision block may be constructed by 2D geometry or table. when create revision button pressed next line should be created just below previous revision line/row.

this is works well except custom standard

CODE --> vb6

If SheetSizeBox.Text = "A4 LANDSCAPE" Then
DrwDocument.Standard = catISO
DrwSheet.PaperSize = catPaperA4
DrwSheet.Orientation = catPaperLandscape
End If 

RE: Titleblock macro to vb6

(OP)
My program works pretty well except one thing. If I modify links in drawing like to set it show me specific part body or geo set than during titleblock creation program won't get part properties. Program only works if a view contains whole part. How to override that

Here's current code

CODE --> vb

'----FILLING PART PROPERTIES----
On Error Resume Next
Set ProductDrawn = DrwSheet.Views.Item(3).GenerativeBehavior.Document

'----DRAWING NUMBER----
Dim DrwNo As String
DrwNo = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString

Set MyTextDrwNo = MyDrawingViews.ActiveView.Texts.Add("DRAWING No.", 246.5, 14)
MyTextDrwNo.Name = "TitleBlock_Text_Title_8"
MyTextDrwNo.SetFontSize 0, 0, 2
MyTextDrwNo.SetFontName 0, 0, "Century Gothic (TrueType)"
MyTextDrwNo.AnchorPosition = catTopLeft
DrwTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString
If (DrwNo <> "") Then
Else
Set MyTextDrwNo = Texts.GetItem("TitleBlock_Text_Title_8")
VariableDrw = InputBox("DRW. No. NOT FOUND! PLEASE ENTER DRAWING NUMBER" & Chr(13) & _
                     " " & Chr(13) & _
                    "GO BACK TO PART PROPERTIES, FILL DRAWING NUMBER AND UPDATE TITLE BLOCK", "DRAWING NUMBER WARRING", "ENTER DRAWING NUMBER")
MyTextDrwNo.Text = VariableDrw
End If 

and so on for all the properties.
The method from sample CatScript which installed with Catia doesn't works for me.

Any help on that will be greatly appreciated.

Cheers.

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