public RotationalJointAxis(string path, Joint current) : base(path, current) { FlipVectors = new DoubleStorageArray(swData, path + "/FlipVectors"); if (FlipVectors.Count == 0) { for (int i = 0; i < 4; i++) FlipVectors.AddItem(0); } }
/// <summary> /// Loads a robot from an assembly document, if a robot dosn't already /// exist one will be created /// </summary> /// <param name="asm">Assembly document containing a robot model</param> /// <param name="swApp">Interface for interacting with Solidworks</param> public RobotModel(AssemblyDoc asm, SldWorks swApp) { RobotInfo.WriteToLogFile("Robot Created (Robot)"); var assembly = typeof(JointSpecifics).Assembly; Type[] types = assembly.GetTypes().Where( t => t.IsSubclassOf(typeof(JointSpecifics)) && !t.IsAbstract).ToArray(); foreach (Type t in types) { System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.TypeHandle); } RobotInfo.WriteToLogFile("Initialized JointTypes = " + String.Join(", ",JointFactory.GetTypesList()) + " (Robot)"); //Setup fields this.swApp = swApp; this.asmDoc = asm; this.modelDoc = (ModelDoc2)asm; swData = new StorageModel(modelDoc); Selected = false; RobotInfo.SetProperties(swApp, asmDoc, swData, this); RobotInfo.WriteToLogFile("Setup Fields Setup"); //If the robot data dosn't exist yet, create it with default values if (swData.GetDouble("robot") == 0) { swData.SetDouble("robot", 1); /*PhysicalConfig = "Default"; VisualConfig = "Default"; CollisionConfig = "Default";*/ Name = ((ModelDoc2)asm).GetTitle(); RobotInfo.WriteToLogFile("Robot Data created with Default Values"); } RobotInfo.WriteToLogFile("Robot Data created"); LinkNums = new DoubleStorageArray(swData, "robot/linkNums"); nextLinkNum = 0; RobotInfo.WriteToLogFile("LinkNums Storage Array Created"); Links = new Dictionary<int,Link>(); //Load link structure Link newLink; if (LinkNums.Count == 0) { LinkNums.AddItem(0); RobotInfo.WriteToLogFile("New Link added to LinkNums"); } Configuration currentConfig = modelDoc.ConfigurationManager.ActiveConfiguration; foreach (double d in LinkNums) { newLink = new Link("robot/link" + (int)d, (int)d); RobotInfo.WriteToLogFile("New Link Created"); Links.Add((int)d,newLink); if (d >= nextLinkNum) nextLinkNum = (int)d + 1; } Links[0].isBaseLink = true; foreach (Link l in Links.Values.ToArray()) { l.InitializeJoints(); l.InitializeAttachments(); } modelDoc.ShowConfiguration2(ConfigName); CalcAxisVectors(); CalcOrigin(); modelDoc.ShowConfiguration2(currentConfig.Name); }