Checking if a component is virtual in a macro?

Hello

In a macro, I would like to check if a component is virtual or not?

I found the IsVirtual command but I can't use it correctly.

Thank you in advance for your answers.

 

Hello

Here is more information: http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.icomponent2~isvirtual.html

See you.

1 Like

Hello

A priori, by retrieving the path of the component, we can know if it is virtual or not (because it will start with "%TEMP/swx"), seehere:

https://forum.solidworks.com/thread/31533

Otherwise, see this example:

http://help.solidworks.com/2014/english/api/sldworksapi/Insert_New_Virtual_Component_Example_VBNET.htm

 

 

In fact, it's simply:

If swChildComp.IsVirtual = False Then

To be integrated into a macro of this type:

http://help.solidworks.com/2013/English/api/sldworksapi/Traverse_Assembly_at_Component_and_Feature_Levels_Using_Recursion_Example_VBNET.htm

 

EDIT: Mistake, I didn't want to post here:)

Hello

Can you post the code in a text file please?

 

A priori, you should use:

Dim swComponent As SldWorks.Component2

Dim ret as boolean

ret = swComponent. IsVirtual 'we get true or false