using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace elementremoval
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
static int Main(string[] args)
{
SetDllDirectory("../../../../../../win64/vc14.1/bin");
string aKey = LicenseKey.Value();
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate CAD Exchanger license.");
return 1;
}
if (args.Length != 3)
{
Console.WriteLine("Usage: " + System.Reflection.Assembly.GetExecutingAssembly().Location +
" <input_file> <output_file> <sge_to_remove>, where:");
Console.WriteLine(" <input_file> is a name of the XML file to be read");
Console.WriteLine(" <output_file> is a name of the CDX file where the output should be stored");
Console.WriteLine(" <sge_to_remove> is a name of the scene graph elements to remove");
return 1;
}
string aSource = args[0];
string anOutput = args[1];
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
string aNameToRemove = args[2];
List<ModelData_SceneGraphElement> aRootsToRemove = new List<ModelData_SceneGraphElement>();
{
var anElement = anIt.Next();
{
aRootsToRemove.Add(anElement);
}
}
foreach (var aRootToRemove in aRootsToRemove)
{
aModel.RemoveRoot(aRootToRemove);
}
RemovedSGEFinder aFinder =
new RemovedSGEFinder(
new Base_UTF16String(aNameToRemove));
aModel.Accept(aFinder);
foreach (var aParentWithChildren in aFinder.SGEsToRemove)
{
var aParent = aParentWithChildren.Key;
var aChildrenToRemove = aParentWithChildren.Value;
foreach (var aChildToRemove in aChildrenToRemove)
{
aParent.RemoveInstance(aChildToRemove);
}
}
return 0;
}
}
{
public Dictionary<ModelData_Assembly, List<ModelData_Instance>> SGEsToRemove { get; set; }
{
myNameToRemove = theNameToRemove;
SGEsToRemove = new Dictionary<ModelData_Assembly, List<ModelData_Instance>>();
}
{
{
if (aChild.Reference() != null && aChild.Reference().Name().Equals(myNameToRemove))
{
RemoveElement(aChild, theElement);
}
}
return true;
}
{
if (SGEsToRemove.ContainsKey(theParent))
{
SGEsToRemove[theParent].Add(theElement);
}
else
{
SGEsToRemove[theParent] = new List<ModelData_Instance>() { theElement } ;
}
}
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
Defines a group of scene graph element.
Definition: ModelData_Assembly.hxx:33
Defines an occurrence of assembly or part in a scene graph.
Definition: ModelData_Instance.hxx:34
Iterator over scene graph elements.
Definition: ModelData_Model.hxx:138
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33
bool Write(const ModelData_Model &theModel, const Base_UTF16String &theFilePath)
Writes the specified model to the file at the specified path.
Definition: ModelData_ModelWriter.cxx:143
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22