Cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically moving all items on drawing sheet 1 to different drawing sheet.

Pioneer
Pioneer

I need to select and move all items on sheet 1 of a drawing including notes, tables, surface finishes and balloons. It would be like selecting all (Ctrl-A) and then move all selected items to a different sheet. Unfortunately the journal does not capture moving views to a different sheet.

 

Running NX 8.5 and using VB.Net

 

Thanks

7 REPLIES

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Honored Contributor
Honored Contributor

The drafting views collection has a .MoveViewsToDrawing method that should move the given views to a new sheet (NX 7.5 or higher).

 

{part}.DraftingViews.MoveViewsToDrawing(draftingviews(), drawingsheet)

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Pioneer
Pioneer

Cowski, that works great for drawing views but I also need to move all notes, symbols and tables too. Do you have any suggestion for those?

 

Thanks

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Honored Contributor
Honored Contributor

Cut & paste to the new sheet. Start the journal recorder then cut and paste a note to a new sheet. The recorded code will give you a good starting point.

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Creator
Creator

Keep an eye on this post as well.

http://community.plm.automation.siemens.com/t5/NX-Programming-Customization/CutCopyPasteBuilder-to-c...

CowSki is right on the journal. I've attached a code snippet to this link but still waiting to here form Siemens support on why it isn't working.  Will add to post when I find out more.  Good Luck.

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Pioneer
Pioneer

Thanks for the heads up. Did you generate the code snippet from the journal?

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Creator
Creator

I ran the journal and condensed it down to what I saw.  The journal was rather lengthy.  Validate returns true at this point but the information doesn't past.  Will up date when I here form support.

Gregg

Re: Programatically moving all items on drawing sheet 1 to different drawing sheet.

Creator
Creator

Create a template of the objects that you want to reuse.  This will create a PAX file.  Add that file to the configuration for NX or Team Center.  I wish I could help with how that is done but I'm new to NX.  Once that was done I was able to generate this journal that went off without a hitch.  I'm still working how to do this without intervension.  It would be use full just to get named instances for Engineering reuse.

public class NXJournal
{
  public static void Main(string[] args)
  {
    Session theSession = Session.GetSession();
    Part workPart = theSession.Parts.Work;
    Part displayPart = theSession.Parts.Display;
    // ----------------------------------------------
    //   Menu: Insert->Sheet...
    // ----------------------------------------------
    NXOpen.Session.UndoMarkId markId1;
    markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");
    
    NXOpen.Drawings.DrawingSheet nullDrawings_DrawingSheet = null;
    NXOpen.Drawings.DrawingSheetBuilder drawingSheetBuilder1;
    drawingSheetBuilder1 = workPart.DrawingSheets.DrawingSheetBuilder(nullDrawings_DrawingSheet);
    
    drawingSheetBuilder1.AutoStartViewCreation = true;
    
    drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11;
    
    drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11;
    
    drawingSheetBuilder1.AutoStartViewCreation = false;
    
    drawingSheetBuilder1.MetricSheetTemplateLocation = "";
    
    drawingSheetBuilder1.EnglishSheetTemplateLocation = "%UGMGR=V3.2 PH=SwXVIAAPx1yBpD PRH=isSVIAAPx1yBpD PN=L3_BDR_TUBE_AV PRN=- RT=\"has shape\" AT=\"UG master part file\" ";
    
    drawingSheetBuilder1.Height = 34.0;
    
    drawingSheetBuilder1.Length = 46.0;
    
    drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11;
    
    drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11;
    
    drawingSheetBuilder1.ScaleNumerator = 1.0;
    
    drawingSheetBuilder1.ScaleDenominator = 1.0;
    
    drawingSheetBuilder1.Units = NXOpen.Drawings.DrawingSheetBuilder.SheetUnits.English;
    
    drawingSheetBuilder1.ProjectionAngle = NXOpen.Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third;
    
    drawingSheetBuilder1.Number = "1";
    
    drawingSheetBuilder1.SecondaryNumber = "";
    
    drawingSheetBuilder1.Revision = "A";
    
    theSession.SetUndoMarkName(markId1, "Sheet Dialog");
    
    drawingSheetBuilder1.EnglishSheetTemplateLocation = "%UGMGR=V3.2 PH=SwXVIAAPx1yBpD PRH=isSVIAAPx1yBpD PN=L3_BDR_TUBE_AV PRN=- RT=\"has shape\" AT=\"UG master part file\" ";
    
    NXOpen.Session.UndoMarkId markId2;
    markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet");
    
    theSession.DeleteUndoMark(markId2, null);
    
    NXOpen.Session.UndoMarkId markId3;
    markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet");
    
    NXObject nXObject1;
    nXObject1 = drawingSheetBuilder1.Commit();
    
    theSession.DeleteUndoMark(markId3, null);
    
    theSession.SetUndoMarkName(markId1, "Sheet");
    
    drawingSheetBuilder1.Destroy();
    
    workPart.Drafting.SetTemplateInstantiationIsComplete(true);
    
    NXOpen.Session.UndoMarkId markId4;
    markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start");
    
    NXOpen.Drawings.ViewCreationWizardBuilder viewCreationWizardBuilder1;
    viewCreationWizardBuilder1 = workPart.DraftingViews.CreateViewCreationWizardBuilder();
    
    viewCreationWizardBuilder1.BaseView = "Back";
    
    viewCreationWizardBuilder1.SpecialBaseView = false;
    
    viewCreationWizardBuilder1.HiddenLineFont = 2;
    
    viewCreationWizardBuilder1.ViewRepresentation = NXOpen.Drawings.ViewCreationWizardBuilder.ViewRepresentations.SmartLightweight;
    
    viewCreationWizardBuilder1.Resolution = NXOpen.Drawings.ViewCreationWizardBuilder.ResolutionOption.Medium;
    
    theSession.SetUndoMarkName(markId4, "View Creation Wizard Dialog");
    
    PartLoadStatus partLoadStatus1;
    partLoadStatus1 = workPart.LoadFully();
    
    partLoadStatus1.Dispose();
    viewCreationWizardBuilder1.Part = workPart;
    
    NXOpen.Assemblies.Arrangement arrangement1 = (NXOpen.Assemblies.Arrangement)workPart.ComponentAssembly.Arrangements.FindObject("Arrangement 1");
    viewCreationWizardBuilder1.ViewStyle.ViewStyleBase.Arrangement.SelectedArrangement = arrangement1;
    
    viewCreationWizardBuilder1.BaseView = "Back";
    
    viewCreationWizardBuilder1.ViewStyle.ViewStyleBase.Part = workPart;
    
    viewCreationWizardBuilder1.ViewStyle.ViewStyleBase.PartName = "%UGMGR=V3.2 PH=yFfVKuBLx1yBpD PRH=yJVVKuBLx1yBpD PN=036678 PRN=- RT=\"has shape\" AT=\"UG master part file\" ";
    
    viewCreationWizardBuilder1.MarginToBorder = 0.75;
    
    viewCreationWizardBuilder1.MarginBetweenViews = 0.25;
    
    // ----------------------------------------------
    //   Dialog Begin View Creation Wizard
    // ----------------------------------------------
    viewCreationWizardBuilder1.Destroy();
    
    theSession.UndoToMark(markId4, null);
    
    theSession.DeleteUndoMark(markId4, null);
    
    // ----------------------------------------------
    //   Menu: Tools->Journal->Stop Recording
    // ----------------------------------------------
    
  }
  public static int GetUnloadOption(string dummy) { return (int)Session.LibraryUnloadOption.Immediately; }
}