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!

Drawing Link text to parameter with macro 2

Status
Not open for further replies.
Replies continue below

Recommended for you

Regarding sheet size prior to title block creation you can read sheet property an then use
"if sheet size A4 then
Else if..." and so on. In current application I don't have one code for different formats, but this is what I'll do in new version. Have to convert and redesign VB6 application to WPF.

Regards,
Jenia Ladkov
 
Well finally i have the job done. At least for now. Many thanks to all you for the help.

How can I change the title of this thread to "Creation of title box and frame" it would be useful for other users.

I created a video with the final result. Hope you like it. :)


Thanks again to all of you.

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
hi Tiago can you help me with this. i saw your youtube vid about the drawing template macro, and it will be very helpful for me. thanks :) have a great day.

regards,
ian
 
can i have a copy of your script and try to use some of your codes. ive been searching for script of inserting a drawing template in catia. i need a script that can update revision number, s/n, pages and the template itself.
 
It will be easier for you if just pick the right thing. Macro is too long and easy to get lost.

So if you want to star with the frame, you will need to draw it.

Let me try to make your life a bit easier.

Here you can find the needed code to access everything you need in drawing, including switch to background

Code:
'Declarations

Dim DrwDocument   As DrawingDocument
Dim DrwSheets     As drawingSheets
Dim DrwSheet      As drawingSheet
Dim DrwView       As DrawingView
Dim DrwTexts      As DrawingTexts
Dim Text          As DrawingText
Dim Fact          As Factory2D
Dim Point         As Point2D
Dim Line          As Line2D
Dim Cicle         As Circle2D
Dim Selection     As Selection
Dim GeomElems     As GeometricElements


Dim selection1 As Selection
Set selection1 = DrwDocument.Selection

Set DrwDocument = CATIA.ActiveDocument
For Each DrwSheet In DrwDocument.Sheets



Dim sheet As Integer
sheet = sheet + 1

DrwDocument.Sheets.Item(sheet).Activate

Set MyDrawingSheets = DrwDocument.Sheets
Set MyDrawingSheet = MyDrawingSheets.ActiveSheet
Set MyDrawingViews = MyDrawingSheet.Views

CATIA.StartCommand ("Sheet Background")

  Set DrwDocument = CATIA.ActiveDocument
  Set DrwSheets = DrwDocument.Sheets
  Set Selection = DrwDocument.Selection
  Set DrwSheet = DrwSheets.ActiveSheet
  Set DrwView = DrwSheet.Views.ActiveView
  Set DrwTexts = DrwView.Texts
  Set Fact = DrwView.Factory2D
  Set GeomElems = DrwView.GeometricElements

Dim DrwViews As DrawingViews  'make background view active
Set DrwViews = MyDrawingSheet.Views

'Find the dimension of each sheet in these variables
 Dim Sheet_Width
 Dim Sheet_Height
    
    Sheet_Width = MyDrawingSheet.GetPaperWidth
    Sheet_Height = MyDrawingSheet.GetPaperHeight
'Here you can add the code to draw the lines, text, points... of the frame
Next

To add a line

Code:
Set Line1 = Fact.CreateLine(Sheet_Width - 26, 20, Sheet_Width - 33, 22)
    selection1.Clear
    selection1.Add (Line1)
    CATIA.ActiveDocument.Selection.VisProperties.SetRealWidth 1, 1
    CATIA.ActiveDocument.Selection.Clear

To insert a text

Code:
Set MyText1 = MyDrawingViews.ActiveView.Texts.Add(("±0,05"), 21, 20)
MyText1.Angle = 90
MyText1.SetFontSize 0, 0, 1.8

Try to make the use of this, with this you can create a lot of things, I would say that you can create the complete frame.



Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Hi Gents,
Could I ask,
Is it possible to pull some of the contents of the part/product properties straight into a drawing without having to use parameters?
Say Part number, Revision & Description ?
Just wondering

cheers
Alan
 
Alan yes it is possible. See my post from June 21, 2017.

Regards,
Jenia Ladkov
 
I've taken a look and the only post on the 21 June refers to " CATIA.StartCommand("Define Contextual Links"), and a send key with enter, to press the ok "
Don't really understand what that's doing.
I was playing with the idea of a few little scripts to copy some of the properties to clipboard to save me going back and forth to the part.
I tend to add 'Material Grade', 'Stock Size' & 'Mass' properties boxes to my parts when I model them.
This is the code I botched together from other bits of code to copy the part number. Cant get it to work properly as it copies the whole path :(

--------------------------------------------------------

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument

Dim drawingDocument1 'As Document

Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 'As DrawingSheets

Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 'As DrawingSheet

Set drawingSheet1 = drawingSheets1.ActiveSheet

Dim drawingViews1 'As DrawingViews

Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 'As DrawingView

Set drawingView1 = drawingViews1.ActiveView

drawingView1.Activate

Dim FullName

FullName = drawingView1.GenerativeBehavior.document.ReferenceProduct.Parent.FullName

strNewNumber = FullName

sString = strNewNumber

'--------------copy to clipboard -------------------------------------

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oWrite = oExec.stdIn

oWrite.WriteLine sString
oWrite.Close

End Sub
 
Hi again, cant find any macro about creating textbox and link it on a parameter.
 
What is your requirement? To get info out of user user properties?

Regards,
Jenia Ladkov
 
Try this:


Code:
Set strParam4 = parameters1.CreateString("Data Aprovou", "")

Set MyText1 = MyDrawingViews.ActiveView.Texts.Add((""), 79.5, 56.5)
MyText1.WrappingWidth = 23
MyText1.SetFontSize 0, 0, 1.8
MyText1.InsertVariable 0, 100, strParam4

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Guys,
Could someone tell me how I get the revision info from the part properties box?
This is so I can copy it straight to clipboard and paste in a drawing without having to open the parent part.

cheers
alan
 
When you open a drawing does catia not load the part into memory?
I always thought it needed to do that to see if the part needed updating.
I could be totally wrong with that statement and probably am :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top