×
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

Generating Balloons via macro and Ballon text source

Generating Balloons via macro and Ballon text source

Generating Balloons via macro and Ballon text source

(OP)
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 http://www.eng-tips.com/viewthread.cfm?qid=133081 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

RE: Generating Balloons via macro and Ballon text source

(OP)
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.

RE: Generating Balloons via macro and Ballon text source

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

https://picasaweb.google.com/102257836106335725208

RE: Generating Balloons via macro and Ballon text source

(OP)
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



RE: Generating Balloons via macro and Ballon text source

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 --> CATScript

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

https://picasaweb.google.com/102257836106335725208

RE: Generating Balloons via macro and Ballon text source

mad

CODE --> CATScript

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

https://picasaweb.google.com/102257836106335725208

RE: Generating Balloons via macro and Ballon text source

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

https://picasaweb.google.com/102257836106335725208

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