my query concern a vba command "IndicateOrSelectElement2d"
In the past we have already used this command through a vba program and it worked perfectly and after installation of new release of catia (v5 r23 sp2) the program doesn't worked anymore.
I isolate the problem (IndicateOrSelectElement2d) and try to use the command in other context.
I take the sample on vba automation but it doesn't work so I call catia hotline and he seems that it works with catia v5 r23 sp3 but not with sp2.
Dim Document,Selection,DrawingSheets,DrawingSheet,DrawingViews,WindowLocation(1),DrawingView,Factory2D,Radius,Circle2D
Dim HardCodedPoint,Status,XCenter,YCenter,InputObjectType(0),TempCircleHasBeenCreatedAtLeastOnce,ExistingPoint
Dim ObjectSelected
Set Document = CATIA.ActiveDocument : Set Selection = Document.Selection : Set DrawingSheets = Document.Sheets
Set DrawingSheet = DrawingSheets.ActiveSheet : Set DrawingViews = DrawingSheet.Views
Set DrawingView = DrawingViews.ActiveView : Set Factory2D = DrawingView.Factory2D
Set HardCodedPoint = Factory2D.CreatePoint(700.,400.)
HardCodedPoint.ReportName = 1 : HardCodedPoint.Construction = False
Status=Document.Indicate2D("click to define the circle center",WindowLocation)
if (Status = "Cancel" Or Status = "Undo" Or Status = "Redo") then Exit Sub
XCenter = WindowLocation(0) : YCenter = WindowLocation(1)
InputObjectType(0)="Point2D"
Status = "MouseMove" : TempCircleHasBeenCreatedAtLeastOnce = 0
Status=Selection.IndicateOrSelectElement2D("select a point or click to locate the circle radius point", _
InputObjectType,false,false,true, _
ObjectSelected,WindowLocation)
do while (Status = "MouseMove")
if (TempCircleHasBeenCreatedAtLeastOnce) then
Selection.Add Circle2D : Selection.Delete
end if
Radius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _
((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter)))
Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius)
TempCircleHasBeenCreatedAtLeastOnce = 1
Status=Selection.IndicateOrSelectElement2D("select a point or click to locate the circle radius point", _
InputObjectType,false,false,true, _
ObjectSelected,WindowLocation)
loop
if (Status = "Cancel" Or Status = "Undo" Or Status = "Redo") then
if (TempCircleHasBeenCreatedAtLeastOnce) then
Selection.Add Circle2D : Selection.Add HardCodedPoint : Selection.Delete
end if
Exit Sub
end if
if (ObjectSelected) then
Set ExistingPoint = Selection.Item2(1).Value : ExistingPoint.GetCoordinates WindowLocation : Selection.Clear
end if
if (TempCircleHasBeenCreatedAtLeastOnce) then
Selection.Add Circle2D : Selection.Delete
end if
Radius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _
((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter)))
Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius) : Selection.Add Circle2D