Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal (.NET) Wavelink objects 2

Status
Not open for further replies.

MSPBenson

Mechanical
Jan 13, 2005
190
Another journal question.

I have the following:


Option Strict Off
Imports System
Imports NXOpen
imports nxopen.uf
imports nxopen.utilities
Imports NXOpen.Assemblies
Imports System.Windows.Forms
Imports System.IO
Imports System.Collections
imports System.Drawing

Module NXJournal

Dim nxs As Session = Session.GetSession()
Dim ufs as UFSession = UFSession.GetUFSession()
Sub Main
'....................Select Objects..........................


Dim my_ui As ui = ui.GetUI

Dim message As String = " Select Surfaces To Section"
Dim title As String = "Selection"

Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim keepHighlighted As Boolean = false
Dim includeFeatures As Boolean = false
Dim response As Selection.Response

Dim selectionAction As Selection.SelectionAction = _
Selection.SelectionAction.ClearAndEnableSpecific

Dim selectionMask_array(1) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = 0
End With


dim selectedobject() as nxobject

response = my_ui.SelectionManager.SelectObjects(message, title, scope, _
selectionAction, includeFeatures, _
keepHighlighted, selectionMask_array, _
selectedObject)

If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
'goto clean_up
End If



'............................................................






'.....Wavelink objects.......

dim cur_part_tag as tag = nxs.parts.work.tag
dim mysurf(selectedobject.length-1) as nxopen.tag
dim wave_objs(selectedobject.length-1) as tag
dim obj as nxobject
'dim mysurf() as nxopen.tag
dim i as integer = 0

for each obj in selectedobject
dim my_null as system.dbnull
dim my_xform as tag
mysurf(0) = obj.tag
messagebox.show(mysurf(0))

ufs.wave.createlinkedbody(mysurf(0),my_xform,cur_part_tag,false,wave_objs(i))

messagebox.show(mysurf(0))

i=i+1
next




'............................
end sub
end module

I can select the objects to wavelink but I get an incorrect first input error when it tries the wavelink command.
Am I passing the wrong tag to this command?
Tho only other area I'm not sure about is the xform.
I don't want to move the wavelink so I've left this null (as per documantation) but I'm not sure Ione this correctly.


Any help with this would be great.




Mark Benson
Aerodynamic Model Designer
 
Replies continue below

Recommended for you

A little more info on this.

It does work as long as the geometry selected is in the same part.
The trouble is that I want to wavelink in from another part.
It leads me to believe that the tag that I get from the object is incorrect if it resides in a child component but I haven't yet worked out the solution.
As always any help greatfully received.


Mark Benson
Aerodynamic Model Designer
 
I'm still stuck on this.
Any help would be great.

Thanks,


Mark Benson
Aerodynamic Model Designer
 

Hi,

you forgot to create an instance of display part..
Now check this code..this works fine for both display part and in assembly context

' NX 4.0.0.25
' Journal created by ernestohari on Thu Sep 27 17:33:50 2007 India Standard Time
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.uf
Imports NXOpen.utilities
Imports NXOpen.Assemblies
Imports System.Windows.Forms
Imports System.IO
Imports System.Collections
Imports System.Drawing

Module NXJournal

Dim nxs As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()

Sub Main()

'....................Select Objects..........................

Dim my_ui As UI = ui.GetUI

Dim message As String = " Select Surfaces To Section"
Dim title As String = "Selection"

Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim keepHighlighted As Boolean = False
Dim includeFeatures As Boolean = False
Dim response As Selection.Response

Dim selectionAction As Selection.SelectionAction = _
Selection.SelectionAction.ClearAndEnableSpecific

Dim selectionMask_array(1) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = 0
End With


Dim selectedobject() As NXObject

response = my_ui.SelectionManager.SelectObjects(message, title, scope, _
selectionAction, includeFeatures, _
keepHighlighted, selectionMask_array, _
selectedObject)

If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
'goto clean_up

' / Exit execution /
Exit Sub
End If

'............................................................

'.....Wavelink objects.......

Dim cur_part_tag As Part = nxs.Parts.Display

Dim wave_objs(selectedobject.Length - 1) As Tag

Dim index As Integer = 0

For index = 0 To selectedobject.Length - 1

Dim my_xform As Tag = Tag.Null
Dim obj_tag As Tag = selectedobject(index).Tag

' / If you working in assembly context /
If (ufs.Assem.IsOccurrence(selectedobject(index).Tag)) Then
obj_tag = ufs.Assem.AskPrototypeOfOcc(selectedobject(index).Tag)
End If

ufs.Wave.CreateLinkedBody(obj_tag, my_xform, cur_part_tag.Tag, False, wave_objs(index))

ufs.Modl.Update()

Next

End Sub


End Module

 
Hariharan,

Thanks for your post. That's now working just how I need it.
Looks like the tag has to be called from the component.

I now have a slightly different issue.
I'm trying to create a tool that creates a wavelink and then trully removes parameters from the wavelink.

I have the section of code that creates the wavelink geometry working and I had a seperate bit of code for the removal of parameters. I'd hoped that the output from the wavelink command, the "Wave_objs" array could be used to input into:
ufs.modl.DeleteobjectParms(Wave_objs)

Unfortunatley it seems that that command requires a different tag.
The question is then, how do I convert the array of tags from the wavelink command in the example to the type of tags required for the remove parameters command.

Cheers,


Mark Benson
Aerodynamic Model Designer
 


Hi Mark,

The output of wave link function yields a feature tag, But the remove parameters function requires a bodytag...So you got use ufs.Mddl.AskfeatObject or ufs.Mddl.AskfeatBody to get the desired tag and pass it as input into the delete parms function.

It should go smooth now

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor