_vaSubtractSolids with C#

Is there a built in C# function to subtract solids from beams? I have been using the following code which works but it adds the solid to subtract to the doc before subtracting and I was wondering if that could be suppressed?

string command = "_vaSubtractSolids " + " SelID " + sourceObj.Id.ToString() + " _Enter " + " SelID " + hole_intersection_guid.ToString() + " _Enter ";

RhinoApp.RunScript(command, false);

Hi @patskorut,

Yes, the method is called AddElementModifier.

Enric

Could you explain more how the AddElementModifier works? I haven’t been able to get it to work. What I am trying to do is I have a beam and I want to subtract a sold circular or rectangular solid from the beam. Here is the code I am using

bool test = va.AddElementModifier(sourceObj.Id, hole_intersection_guid, va.ElementModifierOperation.Subtract);

Looking at the code it should work. Can you please post the full source code and a 3DM sample with the objects?

Enric

Enric,
I played around with the Element Modifier methods a little and I think this is a bug. If I create a beam with some holes and extract the modifiers with va.ExtractElementModifiers() the list of “Guid element_modifiers” gets populated but with empty Guids’ (00000000-0000-0000-0000-000000000000). Here is the code that I tested it with. Try it and let me know, thanks

#r “C:\Program Files\Rhino 8\System\VisualARQ.Script.dll”

using System;
using Rhino;
using Rhino.Collections;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Input;
using Rhino.Input.Custom;
using Rhino.Geometry;
using Rhino.Geometry.Collections;
using System.Collections.Generic;
using VA = VisualARQ.Script;
var doc = RhinoDoc.ActiveDoc;

GetObject get_source_obj;
get_source_obj = new GetObject();
get_source_obj.SetCommandPrompt(“Select objects to subtract from”);
get_source_obj.GeometryFilter = ObjectType.InstanceReference;
get_source_obj.GetMultiple(1, 1);

ObjRef source_obj = get_source_obj.Object(0);

/*
GetObject get_cutting_obj;
get_cutting_obj = new GetObject();
get_cutting_obj.SetCommandPrompt(“Select objects to make hole”);
get_cutting_obj.GeometryFilter = ObjectType.Brep;
get_cutting_obj.GetMultiple(1, 1);
ObjRef cut_obj = get_cutting_obj.Object(0);

bool test = VA.AddElementModifier(source_obj.ObjectId, cut_obj.ObjectId, VA.ElementModifierOperation.Subtract);
/*
Guid element_modifiers = VA.ExtractElementModifiers(source_obj.ObjectId);

doc.Views.Redraw();

Enric,
Did you try this out because I haven’t been able to get the VA.AddElementModifier to work and was wondering if it was something that I was doing? Thanks

Hi @patskorut,

Sorry for the late response.

I’ve been able to reproduce the issue. I’ve already fixed it for the next VisualARQ 3 Beta. Do you need this change in VisualARQ 2? I can make a build of VisualARQ 2.13.3 for you with this change.

Regards,

Enric

Enric,

Thanks for getting back with me, I thought that you guys were busy working on it and I appreciate all your work. If you could send me a link with the build I would like to give it a try because it would make my scripts work a lot better and I’d love to give it a try and update my scripts. Thanks

Hi @patskorut

Which VisualARQ version are you using? 2 or 3?

Enric

I am using VisualARQ 3.

Hi @patskorut,

I have just published a new VisualARQ 3 Beta with the AddElementModifier method fixed.

Regards,

Enric