Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Titleblock macro to vb6

Status
Not open for further replies.

JeniaL

Mechanical
Jun 3, 2014
547
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:
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
 
Replies continue below

Recommended for you

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
 
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?
 
so i got how to get part properties using VB. still can't setup a page.
Code:
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
 
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:
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:
Selection.Search "CATDrwSearch.DrwText,TitleBlock_Text_Title_8_all"
DrwTexts.GetItem("TitleBlock_Text_Title_8").Text = ProductDrawn.ReferenceProduct.UserRefProperties.Item("DRAWING No.").ValueAsString
 

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.[b][COLOR=#CC0000]DrwText.Name=*TitleBlock_Text_Title_8*, [/color][/b]all"
Not
Code:
Selection.Search "CATDrwSearch.DrwText,TitleBlock_Text_Title_8[b]_[/b]all"


Regards,
Maddy

 
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

 
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
Untitled_zydx0b.jpg
 
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.
Untitled_z2ucg3.jpg

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:
If SheetSizeBox.Text = "A4 LANDSCAPE" Then
DrwDocument.Standard = catISO
DrwSheet.PaperSize = catPaperA4
DrwSheet.Orientation = catPaperLandscape
End If
 
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:
'----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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor