Help on Journal for copying surfaces to new layer
Help on Journal for copying surfaces to new layer
(OP)
Hi,
NX8.5.3
I able to change color of faces of geometry which are B-Surfaces to a specific color . Now I want to copy those surfaces to a new layer and then change the color and also the font of the edges to ----- ..
A journal or macro would be awesome for this..
Also, I have seen that there is no way to select surfaces whose faces have a different color than the body color..
As Copy to layer does not allow to pick faces, how can we achieve this?
Please help..
Thanks so much..
NX8.5.3
I able to change color of faces of geometry which are B-Surfaces to a specific color . Now I want to copy those surfaces to a new layer and then change the color and also the font of the edges to ----- ..
A journal or macro would be awesome for this..
Also, I have seen that there is no way to select surfaces whose faces have a different color than the body color..
As Copy to layer does not allow to pick faces, how can we achieve this?
Please help..
Thanks so much..





RE: Help on Journal for copying surfaces to new layer
Using the Extract geometry -> faces command, you can create an associative copy of the face, move it to the desired layer, change the color, etc.
www.nxjournaling.com
RE: Help on Journal for copying surfaces to new layer
How do I do all these operations in one Journal file?
Please can you share a journal on this?
Thanks in advance..
RE: Help on Journal for copying surfaces to new layer
Any luck on this?
RE: Help on Journal for copying surfaces to new layer
I would suggest that you start by recording a journal while creating an extract face feature, then try to incorporate that into the existing code. When that works, then work on adding code to move it to the desired layer. Add code to change the color. Etc etc. Build it up in manageable pieces.
www.nxjournaling.com
RE: Help on Journal for copying surfaces to new layer
RE: Help on Journal for copying surfaces to new layer
Thanks for the support..
You guys are awesome..
RE: Help on Journal for copying surfaces to new layer
I created this journal. Now this works fine on solid body or parasolid with B surfaces.. This errors out if I try to run it on a file which has only surfaces..For example, I do IGES import and run this journal. It errors out..
How can I tune it?
Please help..
RE: Help on Journal for copying surfaces to new layer
I was taking one step more from this thread
thread561-349780: changing color of faces i body: changing color of faces i body
Once I get those yellow faces, I want to extract the surfaces of the faces and then move them to a new layer and change the color and font of the edges of the extracted faces.
Please let me know how I can achieve this..
RE: Help on Journal for copying surfaces to new layer
In the COPYBSURFACE.vb journal, you will see references to:
- wavePointBuilder1
- waveDatumBuilder1
- compositeCurveBuilder1
- extractFaceBuilder1
- mirrorBodyBuilder1
We are only interested in the extractFaceBuilder1; keep the lines that reference the extractFaceBuilder1, and delete the rest. The journal recorder faithfully records the settings in the dialog box as you work; since it doesn't know which option you will be using, it records them all.Next up, you'll see a lot of lines that look like:
CODE
Dim face1 As Face = CType(brep1.FindObject("FACE 6 {(116.8973819204165,165.0696538070952,-8.5412500043044) UNPARAMETERIZED_FEATURE(34)}"), Face)The journal recorder also records the exact entities that you pick while recording. This means that the journal in its current form will only really work when run on that one particular part you had open when you recorded the journal. This is known as "selection stickiness" and we need to remove the dependency on the particular objects in the particular part file to make the code usable in other parts. Delete the lines that reference these particular faces. We'll need to write code that will find the faces for us (this is where the other journal comes in, it finds the B-sufaces, we'll only need to tweak it slightly for our new use).
At this point, the code that extracts the faces looks like this:
CODE
Dim nullFeatures_Feature As Features.Feature = Nothing If Not workPart.Preferences.Modeling.GetHistoryMode Then Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode.")) End If Dim extractFaceBuilder1 As Features.ExtractFaceBuilder extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(nullFeatures_Feature) extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.WorkPart theSession.SetUndoMarkName(markId1, "Extract Geometry Dialog") extractFaceBuilder1.Associative = True extractFaceBuilder1.FixAtCurrentTimestamp = True extractFaceBuilder1.HideOriginal = False extractFaceBuilder1.DeleteHoles = False extractFaceBuilder1.InheritDisplayProperties = False extractFaceBuilder1.Type = Features.ExtractFaceBuilder.ExtractType.Face ' ---------------------------------------------- ' Menu: Edit->Selection->Detailed Filtering... ' ---------------------------------------------- Dim objects1(14) As DisplayableObject Dim added1 As Boolean added1 = extractFaceBuilder1.ObjectToExtract.Add(objects1) Dim markId2 As Session.UndoMarkId markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Extract Geometry") theSession.DeleteUndoMark(markId2, Nothing) Dim markId3 As Session.UndoMarkId markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Extract Geometry") Dim nXObject1 As NXObject nXObject1 = extractFaceBuilder1.Commit() theSession.DeleteUndoMark(markId3, Nothing) theSession.SetUndoMarkName(markId1, "Extract Geometry") extractFaceBuilder1.Destroy()Take note of these lines of code:
CODE
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Module Bsurface_extract_color Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim BFaces As New List(Of DisplayableObject) For Each myBody As Body In workPart.Bodies For Each tempFace As Face In myBody.GetFaces 'lw.WriteLine(tempFace.SolidFaceType.ToString) If tempFace.SolidFaceType = Face.FaceType.Parametric Then BFaces.Add(tempFace) End If Next Next lw.WriteLine(BFaces.Count.ToString & " B surface faces found") lw.Close() End Sub End ModuleIf you run the code above, it will simply report how many B-surface faces were found. You'll see that I used a "list" object to keep track of the faces (as displayable objects). The list object is more convenient to use than an array and it includes a method to convert it to an array - just what we need.
Now, let's copy & paste the extract face code into the other journal and tweak it to use the faces it found.
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Module Bsurface_extract_color Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "extract B-surface faces") Dim BFaces As New List(Of DisplayableObject) For Each myBody As Body In workPart.Bodies For Each tempFace As Face In myBody.GetFaces 'lw.WriteLine(tempFace.SolidFaceType.ToString) If tempFace.SolidFaceType = Face.FaceType.Parametric Then BFaces.Add(tempFace) End If Next Next Dim nullFeatures_Feature As Features.Feature = Nothing Dim extractFaceBuilder1 As Features.ExtractFaceBuilder extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(nullFeatures_Feature) extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.WorkPart extractFaceBuilder1.Associative = True extractFaceBuilder1.FixAtCurrentTimestamp = True extractFaceBuilder1.HideOriginal = False extractFaceBuilder1.DeleteHoles = False extractFaceBuilder1.InheritDisplayProperties = False extractFaceBuilder1.Type = Features.ExtractFaceBuilder.ExtractType.Face Dim added1 As Boolean added1 = extractFaceBuilder1.ObjectToExtract.Add(BFaces.ToArray) Dim nXObject1 As NXObject nXObject1 = extractFaceBuilder1.Commit() extractFaceBuilder1.Destroy() 'lw.WriteLine(BFaces.Count.ToString & " B surface faces found") lw.Close() End Sub End ModuleThe code above will now find all the B-surface faces in any file it is run on and extract them.
www.nxjournaling.com
RE: Help on Journal for copying surfaces to new layer
Thanks for all the support and help ..
I recorded this journal to move the surfaces to new layer and change the color and font of the edge. Now I want to combine the code which you gave me to extract the sheets and this..
Please can you help me ?
Also, Can we integrate Macros into Journal file?
Iam not a code developer, but trying to be one.. :))
RE: Help on Journal for copying surfaces to new layer
CODE
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Module Bsurface_extract_color Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "extract B-surface faces") Dim BFaces As New List(Of DisplayableObject) For Each myBody As Body In workPart.Bodies For Each tempFace As Face In myBody.GetFaces 'lw.WriteLine(tempFace.SolidFaceType.ToString) If tempFace.SolidFaceType = Face.FaceType.Parametric Then BFaces.Add(tempFace) End If Next Next lw.WriteLine(BFaces.Count.ToString & " B surface faces found") Dim nullFeatures_Feature As Features.Feature = Nothing Dim extractFaceBuilder1 As Features.ExtractFaceBuilder extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(nullFeatures_Feature) extractFaceBuilder1.ParentPart = Features.ExtractFaceBuilder.ParentPartType.WorkPart extractFaceBuilder1.Associative = True extractFaceBuilder1.FixAtCurrentTimestamp = True extractFaceBuilder1.HideOriginal = False extractFaceBuilder1.DeleteHoles = False extractFaceBuilder1.InheritDisplayProperties = False extractFaceBuilder1.Type = Features.ExtractFaceBuilder.ExtractType.Face Dim added1 As Boolean added1 = extractFaceBuilder1.ObjectToExtract.Add(BFaces.ToArray) extractFaceBuilder1.Commit() Dim myExtractedFaces() As NXObject myExtractedFaces = extractFaceBuilder1.GetCommittedObjects extractFaceBuilder1.Destroy() Dim theExtractedFaces As New List(Of DisplayableObject) For Each myFeat As Features.ExtractFace In myExtractedFaces lw.WriteLine(myFeat.GetFeatureName) For Each tempBody As Body In myFeat.GetBodies theExtractedFaces.Add(tempBody) Next Next Dim displayModification1 As DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification() displayModification1.ApplyToAllFaces = True displayModification1.ApplyToOwningParts = False displayModification1.NewColor = 130 displayModification1.NewFont = DisplayableObject.ObjectFont.Dashed displayModification1.NewWidth = DisplayableObject.ObjectWidth.Two displayModification1.NewLayer = 220 displayModification1.Apply(theExtractedFaces.ToArray) displayModification1.Dispose() lw.Close() End Sub End Modulewww.nxjournaling.com
RE: Help on Journal for copying surfaces to new layer
You ROCK.. You are awesome.. Thanks a ton to fixing the journal..