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!

Create a positional link to a DrawingComponent in macro 2

Status
Not open for further replies.

ferdo

Mechanical
Jul 4, 2002
2,837
RO
Hi,

I cannot create a positional link to a DrawingComponent (2D ditto, lets say a cross), by picking that ditto, to a text, in macro.

I've tried something like this:

Dim oSelection
oSelection = DrawDoc1.Selection

Dim oInputType(0)
Dim oStatus

oInputType(0) = "DrawingComponent"
oStatus = oSelection.SelectElement2(oInputType, "Select a 2D Component", True)
If (oStatus = "Cancel") Then
Exit Sub
End If

Dim Myselection As Selection
Myselection = CATIA.ActiveDocument.Selection

DrawText1.AssociativeElement = Myselection

Does anyone found a solution for this?


Regards
Fernando

 
Replies continue below

Recommended for you

I can't do it with a ditto...
but i do it for another geometry...


Code:
Sub Positional_Link()

Dim oDocument 'As Document
Set oDocument = CATIA.ActiveDocument

Dim oDrawingDocument 'As DrawingDocument
Set oDrawingDocument = oDocument

Dim oSelection 'As Selection
Set oSelection = oDrawingDocument.Selection

Dim oSheets 'As DrawingSheets
Set oSheets = oDrawingDocument.Sheets
    
Dim oSheet 'As DrawingSheet
Set oSheet = oSheets.Item(1)
    
Dim oView  'As DrawingView
Set oView = oSheet.Views.ActiveView

Dim InputObjectType(0)
Dim oStatus

InputObjectType(0) = "DrawingText"
oStatus = oSelection.SelectElement2(InputObjectType, "Select Text", True)
If (oStatus = "Cancel") Then
Exit Sub
End If

Set SelectedElement = oSelection.Item(1)
Set Text = SelectedElement.Value

oSelection.Clear

ReDim oInputType(1): oInputType(0) = "Line2D": oInputType(1) = "DrawingComponent"

oStatus = oSelection.SelectElement2(oInputType, "Select a 2D Component Or Line", True)
If (oStatus = "Cancel") Then
Exit Sub
End If

Dim oSelection1 'As Selection
Set oSelection1 = oDrawingDocument.Selection

Set Selected = oSelection1.Item(1)
Set Ditto = Selected.Value

Dim o2DComponents 'As DrawingComponents
Set o2DComponents = oView.Components
    
Dim o2DComponent 'As DrawingComponent
'Set o2DComponent = o2DComponents.Item(Ditto.Name)


Text.AssociativeElement = Ditto ' o2DComponent

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top