×
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

Methode HeadTarget failed

Methode HeadTarget failed

Methode HeadTarget failed

(OP)
HI,

I would like de write a macro, for catdrawings, to check to wicht Parts the balloons are linked.
I saw the post Link and try the metode "HeadTaget"
Ther my code:

CODE --> VBA

'**************************************************************
'***  Macro To check witch Part the balloon is pointed      ***
'***                                                        ***
'***  VBA                                                  ***
'***                                                        ***
'**************************************************************

Sub CATMain()

On Error Resume Next
Set MonDessin = CATIA.ActiveDocument
If (Err.Number <> 0) Then
    MsgBox ("Un CATDrawing doit être actif")
   
    Exit Sub
End If
If (InStr(MonDessin.Name, ".CATDrawing")) = 0 Then
    MsgBox ("La fenêtre active doit être un CATDrawing")
        Exit Sub
End If
Err.Clear
On Error GoTo 0

Dim ElemDispatch As CATBaseDispatch
Dim myBalloon As DrawingText
Dim myleaders As DrawingLeaders
Dim myleader As DrawingLeader

Set selection1 = MonDessin.Selection
'selection1.Search "Name=Numéro de pièce*,all" ' CATIA IN FRENCH
selection1.Search "Name=Balloon*,all" ' CATIA IN ENGLICH
   
For i = 1 To selection1.Count
    Set myBalloon = selection1.Item(i).Value
    Set myleaders = myBalloon.Leaders
    Set myleader = myleaders.Item(1)
    Set ElemDispatch = Nothing
    Set ElemDispatch = myleader.HeadTarget
        MsgBox myBalloon.Text & "-" & myleader.Name & "-" & ElemDispatch.Name
   

Next
End Sub 

But it don't works : i allways have the message : "methode HeadTarget failed"

Regards
Marc.

Regards
Marc

RE: Methode HeadTarget failed

I might be wrong but the head target is most likey a generated_item and I don't think it can be retrieved.

RE: Methode HeadTarget failed

I do not know if the solution is in CAA, but for those who do not have access to CAA I am doing some investigation in VBA.

The idea is:

from 2D
Get position of ballonhead (H,V)
Get View plane projection

in 3D:
create new temp part to support temp geometry (I know this will trigger update required for drawingview, open to suggestion)
create a plane similar to plane projection
for each ballonhead, create point on plane (I actually might go with a sketch here to manage H and V)
create infinite line normal to plane passing through point
check distance between line and all bodies from all parts in product
if distance is null then get intersection point
measure intersection point with plane
smallest distance would be of the visible body in drawingview


this part is done
this is still pending

The limitation would be that all parts are projected in drawingview, and view is not made from Scene.

Do you have any idea how to manage those limitation in VBA?


Eric N.
indocti discant et ament meminisse periti

RE: Methode HeadTarget failed

Hello again,

To get the list of parts pointed by balloons you can change the settings in Drafting/Annotation and Dress-up/3D Associativity/Balloon generation =>PartNumber.

I might have gotten the path wrong (I don't know all settings by heart :) ) but you can easily find it.

Let us know if it works for you,
Calin

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