cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected CAM Operation while running Blockstyler GUI

Creator
Creator

Hello everyone,

 

I am trying to run the Postprocessor out of a Blockstyler GUI.

I tried to fetch the selected Operation with this code:

 

objects1(0) = CType(theUI.SelectionManager.GetSelectedObject(0), CAM.NCGroup)

If I run the journal directly it works perfect. If I attach this code to the Blockstyler Button,

it throws an "internal memory access violation".

 

Does anyone have a suggestion how to solve this problem?

 

Edit: I am using NX8.5

 

Best Regards

9 REPLIES

Re: How to get selected CAM Operation while running Blockstyler GUI

Esteemed Contributor
Esteemed Contributor

GetSelectedObject is not an array or do you use GetSelectedObjects() ?

In addition I would fill a variable and test if it is nothing and if not check the type of the object contained.

Additionally the ONT is not fully supported by the SelectionManager prior to NX 10, so it would be better to use the UF wrapper for AskSelectedNodes.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get selected CAM Operation while running Blockstyler GUI

Creator
Creator

Hello,

 

thanks for the help! I will try it as soon as possible :-)

Re: How to get selected CAM Operation while running Blockstyler GUI

To see some samples, look in UGOPEN\SampleNXOpenApplications\.NET\CAM for *OntSelection.vb. These programs are run after the user has selected nodes in the Navigator.

Mark Rief
Retired Siemens

Re: How to get selected CAM Operation while running Blockstyler GUI

Creator
Creator

Hello again,

 

Tried to figure out how to use the wrapper, but failed... Smiley Frustrated

Maybe someone could give me a little hint or a basic line I can modify.

 

Also something I try to understand:

If I call the post processor run with CAMSetup.Postprocess or CAMSetup.PostprocessWithSetting and the Postprocessor run onto an error, it will throw the errormessage "User aborted operation" instead of the errormessage which the postprocessor throws. Is there also a way to fetch the 'correct' error message?

 

Thank you again all for the help,

I really appreciate it!

Re: How to get selected CAM Operation while running Blockstyler GUI

Esteemed Contributor
Esteemed Contributor

WT wrote:

Hello again,

 

Tried to figure out how to use the wrapper, but failed... Smiley Frustrated

Maybe someone could give me a little hint or a basic line I can modify.


Dim tSelectedNodes As Tag() = Nothing
Dim iNodeCount As Integer = 0

theUFSession.UiOnt.AskSelectedNodes(iNodeCount, tSelectedNodes)

If iNodeCount > 0 Then
	For Each tNode As Tag In tSelectedNodes

The user must select the objects in the ONT before your dialog is started, this works best.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get selected CAM Operation while running Blockstyler GUI

Esteemed Contributor
Esteemed Contributor

WT wrote:

Also something I try to understand:

If I call the post processor run with CAMSetup.Postprocess or CAMSetup.PostprocessWithSetting and the Postprocessor run onto an error, it will throw the errormessage "User aborted operation" instead of the errormessage which the postprocessor throws. Is there also a way to fetch the 'correct' error message?


Have you tried:

Try
	'Post Process
	If IO.File.Exists(sFileName) Then IO.File.Delete(sFileName)
	
	theSession.Parts.Work.CAMSetup.Postprocess(theNcGroups, sPostName, sFileName, CAM.CAMSetup.OutputUnits.PostDefined)
Catch E As Exception
	Failure = E.Message
	' or Failure = E.ToString()
End Try

ToSting() will give you the entire text of the exception not only the caption.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX11.0 EAP, NX12.0 EAP

How to Get the Most from Your Signature in the Community

Re: How to get selected CAM Operation while running Blockstyler GUI

Esteemed Contributor
Esteemed Contributor

Although NX10 seems somewhat better in giving you the real error, a lot of time when there's an error in the post, you just get an "error in do_event" message.  If this happens, to see what the REAL error is, you have to look in the log (syslog) file (help -> log file).

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: How to get selected CAM Operation while running Blockstyler GUI


WT wrote:

 

Tried to figure out how to use the wrapper, but failed... Smiley Frustrated

Maybe someone could give me a little hint or a basic line I can modify.

 

 


Did you look at RenameOperationsOntSelection.vb?

Mark Rief
Retired Siemens

Re: How to get selected CAM Operation while running Blockstyler GUI

Creator
Creator

Hello everyone,

 

I was on vacation and then out of office.

It is working now, I was struggling with a last error, but found what I was doing wrong.

 

I tried this:

Dim selectedTags() As NXOpen.Tag = Nothing
Dim selectedCount As Integer = 0
theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)
Dim selectedObject As CAM.CAMObject = Utilities.NXObjectManager.Get(selectedTags(0))
Dim selectedObjects() As CAM.CAMObject = Nothing
selectedObjects(0) = selectedObject
workPart.CAMSetup.Postprocess(selectedObjects, PP, FromPath & "\Postlauf.TAP", CAM.CAMSetup.OutputUnits.Metric)

...which throws me an "Object not instanced..." error.

 

But found out:

Dim selectedTags() As NXOpen.Tag = Nothing
Dim selectedCount As Integer = 0
theUfSession.UiOnt.AskSelectedNodes(selectedCount, selectedTags)
Dim selectedObjects(0) As CAM.CAMObject
selectedObjects(0) = Utilities.NXObjectManager.Get(selectedTags(0))
workPart.CAMSetup.Postprocess(selectedObjects, PP, FromPath & "\Postlauf.TAP", CAM.CAMSetup.OutputUnits.Metric)

Is working perfectly Smiley Happy