public static __DrawingData getSelectedData() { __DrawingData drawing = new __DrawingData(); TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { TSD.ContainerView sheet = drawingHandler.GetActiveDrawing().GetSheet(); try { getPoint(drawing); } catch { drawing.setSheet(sheet); } TSD.DrawingObjectEnumerator selectedObjects = drawingHandler.GetDrawingObjectSelector().GetSelected(); drawing.populate(selectedObjects); } return(drawing); }
private DrawingObject getSingleObjectFromSelection <T>() { TSDrg.DrawingHandler drawingHandler = new TSDrg.DrawingHandler(); TSDrg.DrawingObjectEnumerator dwgObjectEnumerator; dwgObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (dwgObjectEnumerator.GetSize() > 1) { lbl_info.Text = "Please select only one object"; return(null); } else if (dwgObjectEnumerator.GetSize() == 0) { lbl_info.Text = "Please select one object"; return(null); } foreach (DrawingObject drawingObject in dwgObjectEnumerator) { if (drawingObject != null && drawingObject.GetType().IsSubclassOf(typeof(T))) { return(drawingObject); } } return(null); }
/// <summary> /// Connects the drawing interface. /// </summary> /// <returns>A boolean value indicating whether the interface is connected.</returns> public bool Connect() { try { if (this.connection == null) { this.connection = new TSDrawingConnection(); SeparateThread.Execute( delegate { TSDrawingConnection.SetMessageExecutionStatus( TSDrawingConnection.MessageExecutionModeEnum.BY_COMMIT); }); } if (this.events == null) { this.events = new TSDrawingEvents(); this.RegisterEvents(); } } catch (Exception ex) { Debug.WriteLine(ex); this.Disconnect(); } return(this.IsActive); }
private static void getPoint(__DrawingData drawing) { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { TSD.ContainerView sheet = drawingHandler.GetActiveDrawing().GetSheet(); TSD.UI.Picker picker = drawingHandler.GetPicker(); T3D.Point viewPoint = null; TSD.ViewBase selectedView = null; MainForm._form.add_text("Select origin point in drawing view"); picker.PickPoint("Pick one point", out viewPoint, out selectedView); T3D.Point sheetPoint = TSD.Tools.DrawingCoordinateConverter.Convert(selectedView, sheet, viewPoint); if (selectedView != null) { if (selectedView is TSD.View) { drawing.setView(selectedView as TSD.View); } } drawing.setSheet(sheet); drawing.setPoints(viewPoint, sheetPoint); } }
private Tuple <TSDrg.PointList, TSDrg.View> getRectangleCornersFromUser() { TSDrg.DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler(); TSDrg.UI.Picker pointPicker = myDrawingHandler.GetPicker(); TSDrg.PointList myPoints = null; TSDrg.ViewBase myViewBase = null; TSDrg.View myView = myViewBase as TSDrg.View; TSDrg.StringList promptMsg = new TSDrg.StringList(); promptMsg.Add("Select first corner of the rectangle"); promptMsg.Add("Select second corner of the rectangle"); try { pointPicker.PickPoints(2, promptMsg, out myPoints, out myViewBase); myView = myViewBase as TSDrg.View; while (myView == null) { pointPicker.PickPoints(2, promptMsg, out myPoints, out myViewBase); myView = myViewBase as TSDrg.View; } return(new Tuple <TSDrg.PointList, TSDrg.View>(myPoints, myView)); } catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted) { //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH"); lbl_info.Text = "User interrupted action."; return(new Tuple <TSDrg.PointList, TSDrg.View>(myPoints, myView)); } }
private Tuple <TSG.Point, TSDrg.View> GetPointViewFromUser() { TSDrg.DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler(); TSDrg.UI.Picker pointPicker = myDrawingHandler.GetPicker(); TSG.Point myPoint = null; TSDrg.ViewBase myViewBase = null; TSDrg.View myView = myViewBase as TSDrg.View; try { pointPicker.PickPoint("Pick a point to insert dimesnion", out myPoint, out myViewBase); myView = myViewBase as TSDrg.View; while (myView == null) { pointPicker.PickPoint("Selected point is not inside a view. Pick a point to insert dimension", out myPoint, out myViewBase); myView = myViewBase as TSDrg.View; } return(new Tuple <TSG.Point, TSDrg.View>(myPoint, myView)); } catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted) { //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH"); lbl_status.Text = "User interrupted action."; return(new Tuple <TSG.Point, TSDrg.View>(myPoint, myView)); } }
private DrawingObject getSingleObjectFromUser <T>() { DrawingHandler myDrawingHandler = new TSDrg.DrawingHandler(); TSDrg.UI.Picker pointPicker = myDrawingHandler.GetPicker(); DrawingObject usrObject = null; ViewBase myViewBase = null; TSDrg.View myView = myViewBase as TSDrg.View; try { pointPicker.PickObject("Please select a bar", out usrObject, out myViewBase); myView = myViewBase as TSDrg.View; while (myView == null || !(usrObject is T)) { pointPicker.PickObject("Please select a bar", out usrObject, out myViewBase); myView = myViewBase as TSDrg.View; } return(usrObject); } catch (Tekla.Structures.Drawing.PickerInterruptedException interrupted) { //Tekla.Structures.Model.Operations.Operation.DisplayPrompt("THIS METHOD NOT WORKING BECAUSE TEKLA API IS THE WORST THING I HAVE EVER WORKED WITH"); lbl_info.Text = "User interrupted action."; return(usrObject); } }
internal static DrawingObjectEnumerator GetSelectedParts() { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); Drawing activeDrawing = drawingHandler.GetActiveDrawing(); ViewBase sheet = activeDrawing.GetSheet(); DrawingObjectEnumerator objects = sheet.GetAllObjects(); objects.Reset(); DrawingObjectSelector dos = drawingHandler.GetDrawingObjectSelector(); objects = dos.GetSelected(); return(objects); }
public static List <TSD.Drawing> getSelectedDrawings() { List <TSD.Drawing> parsed = new List <TSD.Drawing>(); TSD.DrawingHandler myDrawingHandler = new TSD.DrawingHandler(); TSD.DrawingEnumerator selectionEnum = myDrawingHandler.GetDrawingSelector().GetSelected(); foreach (TSD.Drawing current in selectionEnum) { if (current is TSD.Drawing) { parsed.Add(current as TSD.Drawing); } } return(parsed); }
public static void main(TSD.Drawing drawing) { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); drawingHandler.SetActiveDrawing(drawing, true); bool printingStatus = true; if (UserSettings_GLOBAL._removeClouds) { RemoveClouds.main(); } if (UserControls._pdf) { try { ExportPDF.main(drawing); } catch { printingStatus = false; MainWindow._form.consoleOutput("[ERROR - 4] Failed printing!", "L2"); } } if (UserControls._dwg) { try { ExportDWG.main(drawing); } catch { printingStatus = false; MainWindow._form.consoleOutput("[ERROR - 5] Failed exporting!", "L2"); } } drawingHandler.CloseActiveDrawing(UserSettings_GLOBAL._drawingSave); if (printingStatus == false) { throw new DivideByZeroException(); } }
public static List <DrawingObject> getDwgObjectsFromSelection(Type filterType) { TSDrg.DrawingHandler drawingHandler = new TSDrg.DrawingHandler(); TSDrg.DrawingObjectEnumerator dwgObjectEnumerator; List <DrawingObject> dwgObjs = new List <DrawingObject>(); dwgObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (dwgObjectEnumerator.GetSize() == 0) { return(null); } foreach (DrawingObject drawingObject in dwgObjectEnumerator) { if (drawingObject != null && drawingObject.GetType().IsSubclassOf(filterType)) { dwgObjs.Add(drawingObject); } } return(dwgObjs); }
private List <DrawingObject> getObjectsFromSelection(Type filterType) { TSDrg.DrawingHandler drawingHandler = new TSDrg.DrawingHandler(); TSDrg.DrawingObjectEnumerator dwgObjectEnumerator; List <DrawingObject> dwgObjs = new List <DrawingObject>(); dwgObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (dwgObjectEnumerator.GetSize() == 0) { lbl_info.Text = "Please select at least one object"; return(null); } foreach (DrawingObject drawingObject in dwgObjectEnumerator) { if (drawingObject != null && drawingObject.GetType().IsSubclassOf(filterType)) { dwgObjs.Add(drawingObject); } } return(dwgObjs); }
public void LuoPiirros() { if (laatanLeveys == 0 || laatanKorkeus == 0) { throw new NullReferenceException("Laske tasaukset!"); } Drawing.DrawingHandler dHandler = new Drawing.DrawingHandler(); Drawing.Drawing drawing = new Drawing.GADrawing("standard"); CoordinateSystem cSystem = new CoordinateSystem(new Point(), new Vector(1, 0, 0), new Vector(0, 1, 0)); Drawing.View view = new Drawing.View(drawing.GetSheet(), cSystem, cSystem, new AABB(new Point(-500, -500), new Point(laatanLeveys, laatanKorkeus, 3300))); if (!view.Attributes.LoadAttributes(Paaikkuna.HAKEMISTO + @"\Tiedostot\kantavat_laatat.vi")) { view.Attributes.LoadAttributes("standard"); } view.Attributes.Scale = 50.0; view.Attributes.Shortening.CutParts = false; drawing.PlaceViews(); drawing.Insert(); dHandler.SetActiveDrawing(drawing); view.Insert(); }
public static void Run(Tekla.Technology.Akit.IScript akit) { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); var currentDrawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator parts = Extensions.GetSelectedParts(); foreach (var obj in parts) { var part = obj as TSD.Part; if (part != null) { ViewBase view = part.GetView(); CenterLinesDrawer drawer = new CenterLinesDrawer(part, view); // если деталь - труба или пруток if (Extensions.GetPartProfileType(part).Contains("R")) { drawer.SelectDrawerMethod(new RoundBeamCenterLinesDrawer()); } else // если деталь - пластина if (Extensions.SelectModelObject(part.ModelIdentifier.ID) is TSM.ContourPlate || Extensions.GetPartProfileType(part).Contains("B")) { drawer.SelectDrawerMethod(new PlateCenterLinesDrawer()); } else { drawer.SelectDrawerMethod(new BeamCenterLinesDrawer()); } drawer.DrawPartCenterLines(); } } currentDrawing.CommitChanges(); }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { TSM.Model model = new TSM.Model(); TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); TSG.Vector UpDirection = new TSG.Vector(0.0, 0.0, 1.0); TSD.Size A3 = new TSD.Size(410, 287); TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane()); TSM.ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { TSM.Part selectedPart = (TSM.Part)modelObjectEnum.Current; string USER_FIELD_3 = "", USER_FIELD_4 = ""; selectedPart.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3); selectedPart.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4); USER_FIELD_4 = USER_FIELD_4.Replace("(?)", ""); selectedPart.SetUserProperty("USER_FIELD_4", USER_FIELD_4); if (USER_FIELD_3 == "M") { TSD.Drawing gaDrawing = new TSD.GADrawing("BRAD-Mod-Ass", A3); gaDrawing.Name = selectedPart.Name; gaDrawing.Title1 = "SITEWORK"; gaDrawing.Title2 = USER_FIELD_3 + USER_FIELD_4; gaDrawing.Title3 = ""; gaDrawing.Insert(); drawingHandler.SetActiveDrawing(gaDrawing, false); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane(selectedPart.GetCoordinateSystem())); TSM.Solid tsolid = selectedPart.GetSolid(); TSG.Point tsMinPt = tsolid.MinimumPoint; TSG.Point tsMaxPt = tsolid.MaximumPoint; model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane()); if (selectedPart.Name.Contains("BEAM")) { TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem(); TSG.CoordinateSystem PlanViewCoordSys = new TSG.CoordinateSystem(); PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin); PlanViewCoordSys.AxisX = new TSG.Vector(ModelObjectCoordSys.AxisX) * -1.0; PlanViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY); TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection)); if (tempVector == new TSG.Vector()) { tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection)); } PlanViewCoordSys.AxisX = tempVector.Cross(UpDirection); PlanViewCoordSys.AxisY = tempVector; TSM.Solid solid = selectedPart.GetSolid(); TSG.AABB aabbPlanView = new TSG.AABB(); aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50); aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50); TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass"); PlanView.Name = "TOP"; PlanView.Scale = 10; PlanView.Attributes.Shortening.CutParts = true; PlanView.Attributes.Shortening.MinimumLength = 1200; PlanView.Attributes.Shortening.Offset = 0.5; PlanView.Insert(); PlanView.Attributes.FixedViewPlacing = true; PlanView.Origin = new TSG.Point(100, 200); PlanView.Modify(); TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys; FrontViewCoordSys.AxisX = tempVector.Cross(UpDirection).GetNormal(); FrontViewCoordSys.AxisY = UpDirection.GetNormal(); TSG.AABB aabbFrontView = new TSG.AABB(); aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50); aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50); TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass"); FrontView.Name = "FRONT"; FrontView.Scale = 10; FrontView.Attributes.Shortening.CutParts = true; FrontView.Attributes.Shortening.MinimumLength = 1200; FrontView.Attributes.Shortening.Offset = 0.5; FrontView.Insert(); FrontView.Attributes.FixedViewPlacing = true; FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 2)); FrontView.Modify(); } if (selectedPart.Name.Contains("COLUMN")) { TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem(); TSG.CoordinateSystem PlanViewCoordSys = new TSG.CoordinateSystem(); PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin); PlanViewCoordSys.AxisX = new TSG.Vector(ModelObjectCoordSys.AxisX); PlanViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY); TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection)); if (tempVector == new TSG.Vector()) { tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection)); } TSG.AABB aabbPlanView = new TSG.AABB(); aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50); aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50); TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass"); PlanView.Name = "TOP"; PlanView.Scale = 10; PlanView.Attributes.Shortening.CutParts = true; PlanView.Attributes.Shortening.MinimumLength = 1200; PlanView.Attributes.Shortening.Offset = 0.5; PlanView.Origin = new TSG.Point(100, 200); PlanView.Insert(); PlanView.Attributes.FixedViewPlacing = true; PlanView.Modify(); TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys; FrontViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY).Cross(UpDirection) * -1; TSG.AABB aabbFrontView = new TSG.AABB(); aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50); aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50); TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass"); FrontView.Name = "FRONT"; FrontView.Scale = 10; FrontView.Attributes.Shortening.CutParts = true; FrontView.Attributes.Shortening.MinimumLength = 1200; FrontView.Attributes.Shortening.Offset = 0.5; FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 30)); FrontView.Insert(); FrontView.Attributes.FixedViewPlacing = true; FrontView.Modify(); } drawingHandler.CloseActiveDrawing(true); } } } MessageBox.Show("Drawings Created"); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); } catch { } }
public static __DrawingData getAllData() { __DrawingData drawing = new __DrawingData(); TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { TSD.ContainerView sheet = drawingHandler.GetActiveDrawing().GetSheet(); try { getPoint(drawing); } catch { drawing.setSheet(sheet); } List <Type> types = new List <Type>(); if (UserProperties._mark) { types.Add(typeof(TSD.Mark)); } if (UserProperties._section) { types.Add(typeof(TSD.SectionMark)); } if (UserProperties._detail) { types.Add(typeof(TSD.DetailMark)); } //if (UserProperties._line) types.Add(typeof(TSD.Arc)); PUUDUB PIISAV INFO if (UserProperties._line) { types.Add(typeof(TSD.Line)); } if (UserProperties._line) { types.Add(typeof(TSD.Polyline)); } if (UserProperties._line) { types.Add(typeof(TSD.Circle)); } if (UserProperties._line) { types.Add(typeof(TSD.Cloud)); } if (UserProperties._line) { types.Add(typeof(TSD.Rectangle)); } if (UserProperties._line) { types.Add(typeof(TSD.Polygon)); } if (UserProperties._dim) { types.Add(typeof(TSD.StraightDimensionSet)); } if (UserProperties._txt) { types.Add(typeof(TSD.Text)); } if (UserProperties._txtfile) { types.Add(typeof(TSD.TextFile)); } if (UserProperties._dwg) { types.Add(typeof(TSD.DwgObject)); } if (types.Count != 0) { System.Type[] Types = new System.Type[types.Count]; for (int i = 0; i < types.Count; i++) { Types.SetValue(types[i], i); } TSD.DrawingObjectEnumerator allObjects = sheet.GetAllObjects(Types); drawing.populate(allObjects); } } return(drawing); }
// This application assumes that users have already opened a drawing - an assembly drawing. // The goal is for the user to see that particular assembly // in the model, and to see ONLY that assembly in the model. // Therefore all parts which are not associated with this assembly need to be hidden. // All the clutter needs to be removed from view. // And all parts associated with this assembly need to be visible. // Summary: our goals is for users to see, given the particular assembly drawing that they are in, // just that ONE assembly within the model, and to have all other parts hidden. // Methodology: // 1. We obtain the assembly drawing and go through all the drawing objects within the assembly drawing. We get the identifiers of these //// drawing objects and place them in a list (assemblyPartIdentifierList) // 2. We obtain the identifiers of all the objects in the model and place them on this list too. ///3. We want to hide all objects which are not associated with the assembly drawing which is currently open. ///4. Consequently, we obtain a List of identifiers which contains all the objects in the model APART from the assembly parts of the current assembly ///// we are working on. ///5. We convert this list of identifiers into a TSM.Model Object list, and then again convert this list into an ArrayList. ///6. The array list should contain all the objects we need to hide. ///7. We use the array list to select all the objects which need to be hidden, in the model. ///8. We want to call a macro which hides all the objects currently selected. // Two questions, (1) is the above approach a good and efficient wa to solve the above problem> // Given a drawing is open, how can one call a macro which hides all selected objects? // Your comemnts and criticism would be very much apprieciated. private void GetAssembly() { try { // creates model and drawing handle TSM.Model myModel = new TSM.Model(); TSD.DrawingHandler dh = new TSD.DrawingHandler(); if (dh.GetConnectionStatus() == false) { System.Windows.Forms.MessageBox.Show("Could not connect drawing handler."); return; } // users must have an Assembly drawing open. We want to see the assembly contained in the assembly drawing in the // UI. Hence we first obtain the identifiers of the drawing objects. TSD.Drawing currentDrawing = dh.GetActiveDrawing(); if (currentDrawing == null) { System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open"); return; } TSD.AssemblyDrawing currentAssemblyDrawing = currentDrawing as TSD.AssemblyDrawing; if (currentAssemblyDrawing == null) { System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open"); return; } if (currentAssemblyDrawing != null) { // in order to select in the model space we need to create an array list ArrayList assemblyObjectToBeViewed = new ArrayList(); // we need to add a model object to the array list. We are adding the assembly as the model object for the model object selector to select assemblyObjectToBeViewed.Add( myModel.SelectModelObject(currentAssemblyDrawing.AssemblyIdentifier) ); TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector(); selector.Select(assemblyObjectToBeViewed); TSM.Operations.Operation.RunMacro("ShowOnlySelected.cs"); TSM.Operations.Operation.RunMacro("FitToView.cs"); } else { System.Windows.Forms.MessageBox.Show("Please ensure you have an Assembly drawing open"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
// This application assumes that users have already opened a drawing - an assembly drawing. // The goal is for the user to see that particular assembly // in the model, and to see ONLY that assembly in the model. // Therefore all parts which are not associated with this assembly need to be hidden. // All the clutter needs to be removed from view. // And all parts associated with this assembly need to be visible. // Summary: our goals is for users to see, given the particular assembly drawing that they are in, // just that ONE assembly within the model, and to have all other parts hidden. // Methodology: // 1. We obtain the assembly drawing and go through all the drawing objects within the assembly drawing. We get the identifiers of these //// drawing objects and place them in a list (assemblyPartIdentifierList) // 2. We obtain the identifiers of all the objects in the model and place them on this list too. ///3. We want to hide all objects which are not associated with the assembly drawing which is currently open. ///4. Consequently, we obtain a List of identifiers which contains all the objects in the model APART from the assembly parts of the current assembly ///// we are working on. ///5. We convert this list of identifiers into a TSM.Model Object list, and then again convert this list into an ArrayList. ///6. The array list should contain all the objects we need to hide. ///7. We use the array list to select all the objects which need to be hidden, in the model. ///8. We want to call a macro which hides all the objects currently selected. // Two questions, (1) is the above approach a good and efficient wa to solve the above problem> // Given a drawing is open, how can one call a macro which hides all selected objects? // Your comemnts and criticism would be very much apprieciated. private static void GetAssembly() { try { // creates model and drawing handle TSM.Model myModel = new TSM.Model(); TSD.DrawingHandler dh = new TSD.DrawingHandler(); if (dh.GetConnectionStatus() == false) { System.Windows.Forms.MessageBox.Show("Could not connect drawing handler."); return; } // users must have an Assembly drawing open. We want to see the assembly contained in the assembly drawing in the // UI. Hence we first obtain the identifiers of the drawing objects. TSD.Drawing currentDrawing = dh.GetActiveDrawing(); if (currentDrawing == null) { System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open"); return; } TSD.AssemblyDrawing currentAssemblyDrawing = currentDrawing as TSD.AssemblyDrawing; if (currentAssemblyDrawing == null) { System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open"); return; } if (currentAssemblyDrawing != null) { // in order to select in the model space we need to create an array list ArrayList assemblyObjectToBeViewed = new ArrayList(); // we need to add a model object to the array list. We are adding the assembly as the model object for the model object selector to select assemblyObjectToBeViewed.Add(myModel.SelectModelObject(currentAssemblyDrawing.AssemblyIdentifier)); TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector(); selector.Select(assemblyObjectToBeViewed); TSM.Operations.Operation.RunMacro("ShowOnlySelected.cs"); TSM.Operations.Operation.RunMacro("FitToView.cs"); } else { System.Windows.Forms.MessageBox.Show("Please ensure you have an Assembly drawing open"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
/// <summary>Checks if drawing editor is opened</summary> /// <returns>True if any drawing is opened</returns> public bool IsDrawingOpened() { var drawingHandler = new TSD.DrawingHandler(); return(drawingHandler.GetActiveDrawing() != null); }
public static void redraw(__ViewBaseData input, __ViewBaseData output) { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { if (output.view is TSD.View) { if (UserProperties._view) { if (input.view != null && output.view != null) { repositionViewWithOffset(input.view as TSD.View, output.view as TSD.View); } } if (UserProperties._mark || UserProperties._red || UserProperties._predict) { handleMarks <_Mark_Beam>(input.markBeams, output.markBeams); handleMarks <_Mark_PolyBeam>(input.markPolyBeams, output.markPolyBeams); handleMarks <_Mark_ContourPlate>(input.markContourPlates, output.markContourPlates); handleMarks <_Mark_BoltGroup>(input.markBoltGroup, output.markBoltGroup); handleMarks <_Mark_SingleRebar>(input.markSingleRebars, output.markSingleRebars); handleMarks <_Mark_RebarGroup>(input.markRebarBases, output.markRebarBases); } if (UserProperties._section) { createSectionMarks(input.sectionMarks, output.sectionMarks, output.view as TSD.View); } if (UserProperties._detail) { createDetailMarks(input.detailMarks, output.detailMarks, output.view as TSD.View); } if (UserProperties._txt) { createText(input.txt, output.txt, input, output); } if (UserProperties._dim) { createDimentionLineSets(input.straightDimSets, output.straightDimSets, output.view); } if (UserProperties._line) { //createArcs(input.arcs, output.arcs, input.view, output.view); // PUUDUB PIISAV INFO KAARE TAASLOOMISEKS createLines(input.lines, output.lines, input.view, output.view); createPolylines(input.polylines, output.polylines, input.view, output.view); createCircles(input.circles, output.circles, input.view, output.view); createClouds(input.clouds, output.clouds, input.view, output.view); createRectangles(input.rectangles, output.rectangles, input.view, output.view); createPolygons(input.polygons, output.polygons, input.view, output.view); } } else { if (UserProperties._line) { createLinesNoOffset(input.lines, output.lines, input.view, output.view); } } if (UserProperties._txtfile) { repositionTextFile(input.txtFiles, output.txtFiles, input, output); } if (UserProperties._dwg) { repositionDwgFile(input.dwgRefs, output.dwgRefs, input, output); } output.view.Modify(); } }
void ButtonDoClick(object sender, EventArgs e) { TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler(); TSD.UI.Picker picker = drawingHandler.GetPicker(); TSG.Point point1 = null; TSG.Point point2 = null; TSG.Point point3 = null; TSD.ViewBase view = null; Shell shell = null; try { shell = new Shell(Convert.ToDouble(diameterTextBox.Text), Convert.ToDouble(thicknessTextBox.Text), chamferTopComboBox.SelectedItem.ToString(), chamferBotComboBox.SelectedItem.ToString(), Convert.ToDouble(angleTrimTextBox.Text), Convert.ToDouble(angleRotateTextBox.Text), Convert.ToDouble(angleSectorTextBox.Text), Convert.ToInt32(nPartTextBox.Text)); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (shell != null) { try { picker.PickThreePoints("1st poit", "2nd point", "3rd point", out point1, out point2, out point3, out view); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } double angleP2 = GetAngle(new TSG.Point((point2.X - point1.X), (point2.Y - point1.Y))); double angleP3 = GetAngle(new TSG.Point(((point3.X - point1.X) * Math.Cos(-angleP2) - (point3.Y - point1.Y) * Math.Sin(-angleP2)), ((point3.X - point1.X) * Math.Sin(-angleP2) + (point3.Y - point1.Y) * Math.Cos(-angleP2)))); int kof = ((angleP3 >= 0) && (angleP3 < Math.PI)) ? -1 : 1; double lArc = (shell.diameter / 2 - shell.thickness / 2) * shell.angleSector; for (int i = 0; i < shell.arrLine.Length; i++) { TSG.Point p1 = new TSG.Point((point1.X + (i * lArc / shell.nPart) * Math.Cos(angleP2)), (point1.Y + (i * lArc / shell.nPart) * Math.Sin(angleP2))); TSG.Point p2 = new TSG.Point((point1.X + i * lArc / shell.nPart * Math.Cos(angleP2) + kof * shell.arrLine[i] * Math.Sin(angleP2)), (point1.Y + i * lArc / shell.nPart * Math.Sin(angleP2) - kof * shell.arrLine[i] * Math.Cos(angleP2)));; TSD.Text.TextAttributes txtAtributes = new TSD.Text.TextAttributes(); txtAtributes.Angle = angleP2 * 180 / Math.PI + 90; string dimText = (Math.Round(shell.arrLine[i]).ToString()); TSD.Text dim = new TSD.Text(view, p1, dimText, txtAtributes); dim.Insert(); TSD.Line line = new TSD.Line(view, p1, p2); line.Insert(); } TSD.Line line2 = new TSD.Line(view, point1, new TSG.Point((point1.X + lArc * Math.Cos(angleP2)), (point1.Y + lArc * Math.Sin(angleP2)))); line2.Insert(); } }