Wavelinking faces vb
Wavelinking faces vb
(OP)
So I am trying to implement a solution posted in thread561-197154: Journal (.NET) Wavelink objects but that was for a previous version of NX and I think the coding has changed.
I am receiving the same error as the original poster which reads:
"NXOpen.NXException: The second parameter passed in was invalid"
My code is as follows:
The solution center posts the following code, which I tried to base my code off of:
The solution for the error from the above linked post was as follows:
but with the solution I get an error stating that IsOccurrence is not a part of ufs.Assem. and even though I added the line to set obj_tag = ufs.Assem.IsOccurrence(selectedobject(index).Tag) I still get the error.
I appreciate any help.
I am receiving the same error as the original poster which reads:
"NXOpen.NXException: The second parameter passed in was invalid"
My code is as follows:
CODE --> vb
Public Function link_faces( ByRef SelectFaces() As Face )
Dim tagWorkPart As NXOpen.Tag = theSession.Parts.Work.Tag
Dim tempBody As Body = SelectFaces(0).GetBody()
Dim tempComp As Component = tempBody.OwningComponent
Dim compPart As Part = tempComp.Prototype
Dim linked_feature As NXOpen.Tag = NXOpen.Tag.Null
Dim object_in_part As NXOpen.Tag = theSession.Parts.Work.Views.WorkView.Tag
'Dim xform As NXOpen.Tag = NXOpen.Tag.Null
Dim returnFace(selectFaces.Length-1) As NXOpen.Tag
Dim i as Integer = 0
For Each aFace As Face In selectFaces
Dim xform As NXOpen.Tag = NXOpen.Tag.Null
Dim face_tag As NXOpen.Tag = selectFaces(i).Tag
face_tag = theUFSession.Assem.AskPrototypeOfOcc(selectFaces(i).Tag)
theUfSession.So.CreateXformAssyCtxt( object_in_part, face_tag, NXOpen.Tag.Null, xform)
'theUfSession.Wave.CreateLinkedface(aFace.Tag, xform, selectFaces(i).Tag, True, linked_feature)
theUFSession.Wave.CreateLinkedFace(face_tag,xform, displayPart.tag, True, returnFace(i))
theUfSession.Modl.Update()
i = i + 1
Next
End Function The solution center posts the following code, which I tried to base my code off of:
CODE --> vb
Public Function link_bodies(ByRef comp As Assemblies.Component)
Dim workPart As NXOpen.Tag = s.Parts.Work.Tag
Dim compPart As Part = comp.Prototype
Dim linked_feature As NXOpen.Tag = NXOpen.Tag.Null
Dim object_in_part As NXOpen.Tag = s.Parts.Work.Views.WorkView.Tag
Dim xform As NXOpen.Tag = NXOpen.Tag.Null
For Each aBody As Body In compPart.Bodies
ufs.So.CreateXformAssyCtxt(object_in_part, comp.Tag, NXOpen.Tag.Null, xform)
ufs.Wave.CreateLinkedBody(aBody.Tag, xform, object_in_part, True, linked_feature)
ufs.Modl.Update()
Next
End Function The solution for the error from the above linked post was as follows:
CODE -->
'............................................................
'.....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() but with the solution I get an error stating that IsOccurrence is not a part of ufs.Assem. and even though I added the line to set obj_tag = ufs.Assem.IsOccurrence(selectedobject(index).Tag) I still get the error.
I appreciate any help.





RE: Wavelinking faces vb
theUfSession.So.CreateXformAssyCtxt( object_in_part, face_tag, NXOpen.Tag.Null, xform)
To read:
theUfSession.So.CreateXformAssyCtxt( object_in_part, tempComp.Tag, NXOpen.Tag.Null, xform)
Now to figure out how to pass this face back as a face to be used later.
RE: Wavelinking faces vb
CODE --> vb
Public Function link_bodies(ByRef comp As Assemblies.Component) Dim workPart As NXOpen.Tag = s.Parts.Work.Tag Dim compPart As Part = comp.Prototype Dim linked_feature As NXOpen.Tag = NXOpen.Tag.Null Dim object_in_part As NXOpen.Tag = s.Parts.Work.Views.WorkView.Tag Dim xform As NXOpen.Tag = NXOpen.Tag.Null For Each aBody As Body In compPart.Bodies ufs.So.CreateXformAssyCtxt(object_in_part, comp.Tag, NXOpen.Tag.Null, xform) ufs.Wave.CreateLinkedBody(aBody.Tag, xform, object_in_part, True, linked_feature) ufs.Modl.Update() Next End FunctionDenis Huskic
Data Prep
Kettering University
Class of '17
RE: Wavelinking faces vb
I use that simple callout. Define the face of arrays with the callout to ensure the new face array is the correct size.
RE: Wavelinking faces vb
CODE --> vb
... Dim linkcomp() As assemblies.component = link_bodies(comp) End Sub Public Function link_bodies(ByRef comp As Assemblies.Component) Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim workPart As NXOpen.Tag = s.Parts.Work.Tag Dim compPart As Part = comp.Prototype Dim linked_feature As NXOpen.Tag = NXOpen.Tag.Null Dim object_in_part As NXOpen.Tag = s.Parts.Work.Views.WorkView.Tag Dim xform As NXOpen.Tag = NXOpen.Tag.Null For Each aBody As Body In compPart.Bodies ufs.So.CreateXformAssyCtxt(object_in_part, comp.Tag, NXOpen.Tag.Null, xform) ufs.Wave.CreateLinkedBody(aBody.Tag, xform, object_in_part, True, linked_feature) ufs.Modl.Update() Next End Function End ModuleDenis Huskic
Data Prep
Kettering University
Class of '17
RE: Wavelinking faces vb
You should be able to cut and paste that right in.
Unfortunately I am running for the day but will be back tomorrow and will follow up with you first thing.
Note: you will need a log in to access the GTAC Solution Center:
http://solutions.industrysoftware.automation.sieme...
RE: Wavelinking faces vb
"System.NullReferenceException: Object reference not set to an instance of an object"
for this line
CODE --> vb
I checked all my reference sets and everything is set to "Entire Part" at the moment. Maybe I am not executing it properly.
I have an Assembly file, with 1 parent, 6 children. I tried a child and a parent as the workpart but neither work. Nothing is suppressed as well. Any Ideas?
Denis Huskic
Data Prep
Kettering University
Class of '17
RE: Wavelinking faces vb
RE: Wavelinking faces vb
CODE --> vb
Public Function link_faces( ByRef SelectFaces() As Face ) Dim tagWorkPart As NXOpen.Tag = theSession.Parts.Work.Tag Dim tempBody As Body = SelectFaces(0).GetBody() Dim tempComp As Component = tempBody.OwningComponent Dim compPart As Part = tempComp.Prototype Dim linked_feature As NXOpen.Tag = NXOpen.Tag.Null Dim object_in_part As NXOpen.Tag = theSession.Parts.Work.Views.WorkView.Tag Dim returnFace(selectFaces.Length-1) As NXOpen.Tag Dim i As Integer = 0 '------------------------------------------------------------------------------------------ ' Wavelink faces to allow for associative manipulation of faces. ' Original Example found on Siemens Solution center titled "Wave Link all bodies from ' selected component" '------------------------------------------------------------------------------------------ For Each aFace As Face In selectFaces Dim xform As NXOpen.Tag = NXOpen.Tag.Null Dim face_tag As NXOpen.Tag = selectFaces(i).Tag face_tag = theUFSession.Assem.AskPrototypeOfOcc(selectFaces(i).Tag) theUfSession.So.CreateXformAssyCtxt( object_in_part, tempComp.Tag, NXOpen.Tag.Null, xform) theUFSession.Wave.CreateLinkedFace(face_tag,xform, displayPart.tag, True, returnFace(i)) theUfSession.Modl.Update() i = i + 1 Next '------------------------------------------------------------------------------------------ ' At this point the wavelinked-faces will show up in the part navigator, but need to convert ' Xform to faces to pass back into the program to be used later ' Convert the Wavelinked face first to an extracted face, then use get face an an array ' List to finally convert the feature back into a face for later use '------------------------------------------------------------------------------------------ Dim extractedFaces(selectFaces.Length-1) As Features.ExtractFace Dim faceArrayTemp() As Face Dim aLFinalFace As New ArrayList() i = 0 For Each aFace2 As NXOpen.Tag in returnFace ExtractedFaces(i) = NXObjectManager.Get(aFace2) i = i + 1 Next For Each aFace3 As Features.ExtractFace in ExtractedFaces ReDim faceArrayTemp( aFace3.GetFaces.Length-1) faceArrayTemp = aFace3.GetFaces() For Each aFace4 As Face in faceArrayTemp aLFinalFace.Add( aFace4 ) Next Next Dim finalFace As Face() = CType(alFinalFace.ToArray(GetType(Face)), Face() ) Return finalFace End FunctionSome error handling should be added, but I used an ArrayList which I found to be a much easier way to manipulate arrays then the way I was attempting before. There are other methods to accomplish this same thing but I was unable to get them to work. One of which was to use askLinkedFeatureGeom but the only example of its use I could find was in C and I am not proficient enough to get it to work in vb.
Hope this helps someone in the future.