Cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in getting dotted lines of given part in drafting

Builder
Builder

Hello Everyone,

I would  like to get dotted lines of given part in drafting.

I have following code.

I am getting errors in that.

Pls do some modification or give some corrections.

 

using System;
using NXOpen;
using NXOpen.UF;


static class Module1
{
private static Session theSession = Session.GetSession();
private static UI ui = UI.GetUI();
private static UFSession ufs = UFSession.GetUFSession();
private static Part workPart = theSession.Parts.Work;
private static ListingWindow lw = theSession.ListingWindow;

public static void Main()
{


TaggedObject[] selectedviews = new TaggedObject[0];
Selection.Response response1 = Selection.Response.Cancel;

response1 = SelectDraftingView(ref selectedviews);

EditView(selectedviews);
}

public static void EditView(TaggedObject[] selectedviews)
{
Session.UndoMarkId markId3;

String status;

foreach (NXOpen.Drawings.DraftingView selectedview in selectedviews)
{
if (selectedview.Style.HiddenLines.HiddenlineFont == Preferences.Font.Invisible) //Error is coming here
{
selectedview.Style.HiddenLines.HiddenlineFont = Preferences.Font.dashed;    //Error is coming here

workPart.DraftingViews.SuppressViewBreaks(selectedview);
selectedview.Commit();
workPart.DraftingViews.RestoreViewBreaks(selectedview);
}
else if (selectedview.Style.HiddenLines.HiddenlineFont == Preferences.Font.dashed) //Error is coming here
{
selectedview.Style.HiddenLines.HiddenlineFont = Preferences.Font.Invisible;  //Error is coming here

workPart.DraftingViews.SuppressViewBreaks(selectedview);
selectedview.Commit();
workPart.DraftingViews.RestoreViewBreaks(selectedview);
}
}

int nErrs1;
nErrs1 = theSession.UpdateManager.DoUpdate(markId3); //Error is coming here
}

public static Selection.Response SelectDraftingView(ref TaggedObject[] selobj)
{
UI theUI = UI.GetUI();


Selection.Response resp = Selection.Response.Cancel;
string prompt = "Select a drafting view";
string message = "Select a drafting view";
// string title = "Selection";
Selection.SelectionScope scope = Selection.SelectionScope.WorkPart;
Selection.SelectionAction selAction = Selection.SelectionAction.ClearAndEnableSpecific;
Point3d cursor = new Point3d(0, 0, 0);
Selection.MaskTriple[] selectionMask_array = new Selection.MaskTriple[1];
bool includeFeatures = false;
bool keepHighlighted = false;

{
var withBlock = selectionMask_array[0];
withBlock.Type = UFConstants.UF_view_type;
withBlock.Subtype = UFConstants.UF_all_subtype;
}

resp = theUI.SelectionManager.SelectTaggedObjects(prompt, message, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, out selobj);

if (resp == Selection.Response.ObjectSelected || resp == Selection.Response.ObjectSelectedByName)
return Selection.Response.Ok;
else
return Selection.Response.Cancel;
}

public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.Immediately; }
}

4 REPLIES 4

Re: Problem in getting dotted lines of given part in drafting

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Try fully qualifying the references to Preferences. Also, the "dashed" enumeration name should be capitalized ("Dashed" instead of "dashed").

 

Preferences.Font.Invisible
NXOpen.Preferences.Font.Invisible

 

The markId3 undo mark is declared but never set; this leads to an error on the DoUpdate call.

 

In the SelectDraftingView function, it looks like you are attempting to use a VB style "With" block - don't do that, C# doesn't have a direct equivalent.

{
var withBlock = selectionMask_array[0];
withBlock.Type = UFConstants.UF_view_type;
withBlock.Subtype = UFConstants.UF_all_subtype;
}

selectionMask_array[0].Type = UFConstants.UF_view_type;
selectionMask_array[0].Subtype = UFConstants.UF_all_subtype;

 

Re: Problem in getting dotted lines of given part in drafting

Builder
Builder
Thank You Very Much Sir

Re: Problem in getting dotted lines of given part in drafting

Builder
Builder
Hello Sir,
@cowski1
As above code opens dialog box for selecting drafting view(Front, Top and Side) while in drafting for creating hidden lines.
Now what I have done is this.
I have 3 Method as follows
CreateModel()
CreateDratingView()
CreateHiddenLines()
I am creating a model by one dialog box designed by Block UI Styler and I have put above code in this dialog box by creating one method that is CreateHiddenLines() method.

First Model creates by calling CreateModel() method.
Second Getting drafting view by calling CreateDratingView() method.
But getting error at the time of call of CreateHiddenLines() method
Errors are as follows
1. Cannot change application while a dialog is active.
2. Fatal error detected unable to continue died displaying error method.
How to solve this problem?
Any changes in above code

Re: Problem in getting dotted lines of given part in drafting

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

I don't have much experience with the NX block styler; hopefully someone else will be able to give you better answers. As I see it, you have 2 options:

  1. Don't switch applications while the dialog is open. There are a few cases where switching applications while your code is running is required to accomplish a certain task, but normally it isn't necessary. Try commenting out the code that switches applications and see if you encounter any errors or odd behavior.
  2. Close your dialog before switching applications and reopen it after the switch is complete (if it is still required).