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!

Methode HeadTarget failed

Status
Not open for further replies.

MarcL68

Mechanical
Jun 5, 2013
35
FR
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:
'**************************************************************
'***  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
 
 http://files.engineering.com/getfile.aspx?folder=295556bc-babd-4903-8695-4df4648a68be&file=HEADTARGET_FAILED.jpg
Replies continue below

Recommended for you

I might be wrong but the head target is most likey a generated_item and I don't think it can be retrieved.
 
Hi,
I try with generated geometry and with a line that I create in the drawing : with the line it works (see picture).

Has someone an idea how to retriev the list off the Parts pointed from the balloons?

Regards
Marc
 
 http://files.engineering.com/getfile.aspx?folder=7a2aab10-5e99-484a-a0a8-e307f01b99fe&file=Head_Target_LINE1.jpg
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top