AnsweredAssumed Answered

using SelectByRay

Question asked by Alexander Volkov on Feb 1, 2020
Latest reply on Feb 3, 2020 by Fifi Riri

Hi, everybody!

I'm trying to write macros to add ordinate Dimension, but method SelectByRay does not working. 

Solidworks record macro, but when run macro, it execute only AddOrdinateDimension

 

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;

namespace Macro1.csproj
{
public partial class SolidWorksMacro
{


public void Main()
{


ModelDoc2 swDoc = null;
PartDoc swPart = null;
DrawingDoc swDrawing = null;
AssemblyDoc swAssembly = null;
bool boolstatus = false;
int longstatus = 0;
int longwarnings = 0;
swDoc = ((ModelDoc2)(swApp.ActiveDoc));
ModelView myModelView = null;
myModelView = ((ModelView)(swDoc.ActiveView));
myModelView.FrameState = ((int)(swWindowState_e.swWindowMaximized));
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateView("Front");
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateSheet("Лист1");
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateView("Слева");
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateSheet("Лист1");
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateView("Слева");
boolstatus = swDoc.Extension.SelectByID2("Point1@Sketch2@Left_2513.0002-XX_2450.00000437-XX_1-6@Слева", "EXTSKETCHPOINT", 0, 0, 0, false, 0, null, 0);
//
// Vertical Ordinate Dimension
longwarnings = swDoc.Extension.AddOrdinateDimension(2, 0.3686965293215061501, 0.1428529440913848814, 0);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByRay(0.3792170666658048472, 0.1486479905188686779, -2999.715999999999894, 0, 0, -1, 6.611797961296777464e-05, 1, false, 0, 0);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByRay(0.3796391784630119837, 0.1580754699585562029, -2999.715999999999894, 0, 0, -1, 0.000589514547664962826, 1, false, 0, 0);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByRay(0.3791190185680134439, 0.1715996272285171265, -2999.715999999999894, 0, 0, -1, 0.000589514547664962826, 1, false, 0, 0);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByRay(0.3792924051996796608, 0.1863374909201412077, -2999.715999999999894, 0, 0, -1, 0.000589514547664962826, 1, false, 0, 0);
swDoc.ClearSelection2(true);
boolstatus = swDoc.Extension.SelectByRay(0.3792924051996796608, 0.1953535957667817957, -2999.715999999999894, 0, 0, -1, 0.000589514547664962826, 1, false, 0, 0);
swDoc.ClearSelection2(true);
swDoc.SetPickMode();
swDrawing = ((DrawingDoc)(swDoc));
boolstatus = swDrawing.ActivateView("Front");
}

/// <summary>
/// The SldWorks swApp variable is pre-assigned for you.
/// </summary>
public SldWorks swApp;
}
}

Outcomes