AnsweredAssumed Answered

Unable to use SelectByID2 in C#

Question asked by Oleg Oleg on Sep 23, 2017
Latest reply on Sep 25, 2017 by Jacob Corder

Hello, i'm using SW 2016 and VS 2015. So yesterday i wrote a piece of program that creates a 3d model in SW. It worked perfect yesterday. But today i receive error in VS:

 

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SWMod.exe

Additional information: Ошибка на сервере. (Исключение из HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

 

Error goes from line:

boolstatus = swDoc.Extension.SelectByID2("", "FACE", -0.028779301900519944, 0.0099999999999909051, -0.0013146100868138169, false, 0, null, 0);

 

It works when i put something in first argument of SelectByID2 function (SelectByID2("Front plane", "FACE"...).

So as i thought from first argument of SelectByID2 function, program cant get an object to select, when i do macro, SW puts an empty string if object is not defined(object with name or orientation such as front plane).

 

I tried to do the same in SW 2017, and it works fine, because SW 2017 uses SelectByRay method which arguments have coordinates only, but my 2016 SW does not have this method in library(sldworks;swcommands;swconst). And so i cant name object, because i need to select it first. How do i select object without error?

Outcomes