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!

Generating Balloons via macro and Ballon text source

Status
Not open for further replies.

kicosh

Automotive
Mar 22, 2012
10
HR
Hello all!

Is there a way to change Ballon text source via macro?

To clarify: When you go Tools/Options/Mechanical Design/Drafting and than on "Annotation and Dress-Ups" tab you have combobox to choose whether balloons will show Numbering, Part Number or Instance Name. I have been struggling for days and digging through Automation help file and VBA object browser to find an answer but couldn't find anything on the matter.

Also, is there a way to generate balloons via macro without using start command? I am asking this because the only way i know how to do this is start command, since i haven't found anything in help file on the matter also.

I also tried to dump parameter values for "Annotation and Dress-Ups" tab but file generated is empty.

And in the end, is there a way to set up Balloon text source to some other parameter besides Numbering, Part Number and Instance Name.

I am asking this cos i am trying to somehow overcome first level numbering problem. In this topic shasbarg said that in their company they numbered subassemblies through instance description, which i understand how, but the thing i don't get is how to populate balloons with these values.

Thank you in advance
 
Replies continue below

Recommended for you

Sorry i forgot about something else.

Since i could't find anything about this too...

Is there a way to loop through all balloons in view. Meaning, are balloons recognized as balloon object or some other object and what collection they belong to.
 
Hi,

This is something which I was also interested at one moment and at that time I found an answer on net (can't remember where and who posted this).

Balloons are presented in Automation as DrawingText objects, because basically balloon is a text with round frame, leader and positional link to target object (all of this can be set up programmatically).

In order to create "real" balloon programmaticlly your easiest and most likely only option is to copy-paste one that is already in a drawing and modify it's properties according to your needs. This way you depend on having at least one balloon in your drawing. To be sure that it is present you can:

a) easy way: ask user to create one before launching your macro.
b) hard way: using CATIA.StartCommand method (as you know), launch balloon creation command, enter any text in
opened dialog window (with WinAPI) and then send a mouse click to drawing editor window to indicate position of balloon (WinAPI again).

Either way you should have balloon in your document that you are able to operate with.

To loop thru all your balloons, I believe you can also search for name = Balloon and create a Selection....

Regards
Fernando

 
Ferdo, these infos you provided help a lot. Thanks for reply. In next few days i will play with this and hopefully come up with something.

Few things though...

This copy/paste method you proposed seems like a good idea, but what i don't know is how to programmicaly modify position of Balloon leader anchor point to point to specific object.
To clarify: you need to loop through all components in a view/s that are generated from 3D model and find its position in screen in order to indicate X,Y position of mouse click. Is this even possible? If not i don't actually see much sense in doing this because you would have to manually reposition all leaders, and this is something Catia provides anyway.

If this is not possible, then is there a way to know to what object are Catia automatically generated balloons pointing to? This would help a lot.

what you proposed under a) could also be done via CATIA.StartCommand so you don't have to ask user to create one.

that's all for now. thanks for reply again



 
I don't know if this will help but create a drawing with one balloon and test the code bellow, maybe will give you new ideas (it will move the leader from one point to another).

Code:
Option Explicit

Sub CATMain()
    
    ' Access through document's structure
    Dim DrwDoc As DrawingDocument
    Set DrwDoc = CATIA.ActiveDocument
    
    Dim colSheets As DrawingSheets
    Set colSheets = DrwDoc.Sheets

    Dim ActSheet As DrawingSheet
    Set ActSheet = colSheets.ActiveSheet
    
    Dim colViews As DrawingViews
    Set colViews = ActSheet.Views
    
    Dim ActView As DrawingView
    Set ActView = colViews.ActiveView
        
    ' get first text from active view
    Dim txtFirstText As DrawingText
    Set txtFirstText = ActView.Texts.Item(1)   'just first one
    
    ' get leaders collection for first text
    Dim colLeaders As DrawingLeaders
    Set colLeaders = txtFirstText.Leaders
    
    Dim ldrCurLeader As DrawingLeader
    Dim objCurLeader As AnyObject
    
    Dim ArrLeaderPoints() As Variant
    Dim dblAnchorX As Double
    Dim dblAnchorY As Double
    Dim dblTextX As Double
    Dim dblTextY As Double
    
    Dim iPointsCount As Integer
    
    For Each ldrCurLeader In colLeaders

            ' get coordinates of anchor point
            Call ldrCurLeader.GetPoint(1, dblAnchorX, dblAnchorY)
            MsgBox "Leader point coordinates are:  " & dblAnchorX & "    "  & dblAnchorY
            
            '~ Call ldrCurLeader.RemovePoint(1)   ''uncomment if you want to remove the leader         
            dblTextX = dblAnchorX + 100
            dblTextY = dblAnchorY + 100
            MsgBox "New leader point coordinates are:  " &  dblTextX & "    "  & dblTextY
            
                            Call ldrCurLeader.ModifyPoint(1, dblTextX, dblTextY)
            
    Next ' ldrCurLeader
    
End Sub

Regards
Fernando

 
[mad]

Code:
Option Explicit

Sub CATMain()

    ' Access through document's structure
    Dim DrwDoc As DrawingDocument
    Set DrwDoc = CATIA.ActiveDocument

    Dim colSheets As DrawingSheets
    Set colSheets = DrwDoc.Sheets

    Dim ActSheet As DrawingSheet
    Set ActSheet = colSheets.ActiveSheet

    Dim colViews As DrawingViews
    Set colViews = ActSheet.Views

    Dim ActView As DrawingView
    Set ActView = colViews.ActiveView

    ' get first text from active view
    Dim txtFirstText As DrawingText
    Set txtFirstText = ActView.Texts.Item(1)   'just first one, for second put 2 a.s.o.

    ' get leaders collection for first text
    Dim colLeaders As DrawingLeaders
    Set colLeaders = txtFirstText.Leaders


    ' "straighten up" each leader
    Dim ldrCurLeader As DrawingLeader
    Dim objCurLeader As AnyObject

    Dim ArrLeaderPoints() As Variant
    Dim dblAnchorX As Double
    Dim dblAnchorY As Double
    Dim dblTextX As Double
    Dim dblTextY As Double

    Dim iPointsCount As Integer

    For Each ldrCurLeader In colLeaders

            ' get coordinates of anchor point
            Call ldrCurLeader.GetPoint(1, dblAnchorX, dblAnchorY)
            MsgBox "Leader point coordinates are:  " & dblAnchorX & "    "  & dblAnchorY

            '~ Call ldrCurLeader.RemovePoint(1)   ''uncomment if you want to remove the leader
            dblTextX = dblAnchorX + 100
            dblTextY = dblAnchorY + 100
            MsgBox "New leader point coordinates are:  " &  dblTextX & "    "  & dblTextY

                            Call ldrCurLeader.ModifyPoint(1, dblTextX, dblTextY)

    Next ' ldrCurLeader

End Sub

Regards
Fernando

 
I give up, no way to use "code" and have a nice text format...it was better before last improvement of the forum...

Option Explicit

Sub CATMain()

' Access through document's structure
Dim DrwDoc As DrawingDocument
Set DrwDoc = CATIA.ActiveDocument

Dim colSheets As DrawingSheets
Set colSheets = DrwDoc.Sheets

Dim ActSheet As DrawingSheet
Set ActSheet = colSheets.ActiveSheet

Dim colViews As DrawingViews
Set colViews = ActSheet.Views

Dim ActView As DrawingView
Set ActView = colViews.ActiveView

' get first text from active view
Dim txtFirstText As DrawingText
Set txtFirstText = ActView.Texts.Item(1) 'just first one, for second put 2 a.s.o.

' get leaders collection for first text
Dim colLeaders As DrawingLeaders
Set colLeaders = txtFirstText.Leaders


' "straighten up" each leader
Dim ldrCurLeader As DrawingLeader
Dim objCurLeader As AnyObject

Dim ArrLeaderPoints() As Variant
Dim dblAnchorX As Double
Dim dblAnchorY As Double
Dim dblTextX As Double
Dim dblTextY As Double

Dim iPointsCount As Integer

For Each ldrCurLeader In colLeaders

' get coordinates of anchor point
Call ldrCurLeader.GetPoint(1, dblAnchorX, dblAnchorY)
MsgBox "Leader point coordinates are: " & dblAnchorX & " " & dblAnchorY

'~ Call ldrCurLeader.RemovePoint(1) ''uncomment if you want to remove the leader
dblTextX = dblAnchorX + 100
dblTextY = dblAnchorY + 100
MsgBox "New leader point coordinates are: " & dblTextX & " " & dblTextY

Call ldrCurLeader.ModifyPoint(1, dblTextX, dblTextY)

Next ' ldrCurLeader

End Sub

Regards
Fernando

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top