Journal-wave link all visible bodies from all components
Journal-wave link all visible bodies from all components
(OP)
My manufacturing project workflow starts as the next:
Open the workpiece part; create new parent, link all solid bodies from the part under 'MODEL' reference set.
When I try to record this process, it records like:
I know the name of the component, which contains the needed body. I know, that the bodies are visible, because i check the models when i open it.
Could someone please help me?
Open the workpiece part; create new parent, link all solid bodies from the part under 'MODEL' reference set.
When I try to record this process, it records like:
CODE -->
Dim component1 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT model2 1"), Assemblies.Component)
Dim body1 As Body = CType(component1.FindObject("PROTO#.Bodies|BLOCK(1)"), Body) Could someone please help me?
----
kukelyk





RE: Journal-wave link all visible bodies from all components
I have a journal to setup EDM electrode´s
As it is now - following functions.
1.Your workpiece part must be displayed part.
2.Staying in modelling
3.Run journal ...
4.New part is created , workpiece part is now component name.
5.Name of new part is as component name+"ELEKTRODE_NR--1.
6.New part is located in same dir as workpiece part ´
7.If you run it again with workpiece part as displayed part, new name will be incremented 1. (component name+"ELEKTRODE_NR--2), (component name+"ELEKTRODE_NR--3) and so on...
8.A linked body will be created on layer 12 - color is change to 31 ,cyan.
9.Component is blanked .
-----------------
I think it easy can be can be changed to meet your requirements.
lklo
RE: Journal-wave link all visible bodies from all components
First of all I need this for EDM electrodes' manufacturing too.
----
kukelyk
RE: Journal-wave link all visible bodies from all components
----
kukelyk
RE: Journal-wave link all visible bodies from all components
I will upload a zip file tonight..
lklo
RE: Journal-wave link all visible bodies from all components
lklo
RE: Journal-wave link all visible bodies from all components
lklo
RE: Journal-wave link all visible bodies from all components
----
kukelyk
RE: Journal-wave link all visible bodies from all components
CODE
www.nxjournaling.com
RE: Journal-wave link all visible bodies from all components
CODE --> vb
which refers to this line
CODE --> vb
RE: Journal-wave link all visible bodies from all components
www.nxjournaling.com
RE: Journal-wave link all visible bodies from all components
RE: Journal-wave link all visible bodies from all components
I dont have nx7.5 ,
but I suggest you to simply make a simple journal record,
containing a sequence where you make a procedure with "Create New Parent".
after that - see the records specialy the > fileNew1.***** lines < , maybee you see an difference.
maybee >fileNew1.UseBlankTemplate=False< should bee True.??
ps: of course the > fileNew1.NewFileName = FinalNewPartName < , should bee as it is.
lklo
RE: Journal-wave link all visible bodies from all components
Therefore, I commented out the
'nXObject1 = fileNew1.Commit()
line and now I am having issues with the component command line. It is saying there is an issue with an object I called for this command.
"incorrect object for this operation"
CODE --> vb
Option Strict Off Imports System Imports System.IO Imports NXOpen Imports NXOpen.UF Module NXJournal Sub Main Dim theUI As UI = UI.GetUI() Dim theSession As Session = Session.GetSession() Dim lw As ListingWindow = theSession.ListingWindow() Dim ufs As UFSession = UFSession.GetUFSession() Dim partname As String Dim workpart As Part = theSession.Parts.work Dim disp_partname As String Dim displayPart As Part = theSession.Parts.Display Dim comp As String Dim Revcomp As String Dim insert as String partname = path.GetFileNameWithoutExtension(workPart.FullPath) comp = partname insert = "__Rev" Revcomp = comp .insert(5, insert) 'Msgbox(comp & chr(13) & Revcomp) Dim partLoadStatus2 As PartLoadStatus Dim status1 As PartCollection.SdpsStatus status1 = theSession.Parts.SetDisplay(displaypart, False, True, partLoadStatus2) workPart = theSession.Parts.Work displayPart = theSession.Parts.Display partLoadStatus2.Dispose() 'Msgbox(partname) 'To find folder name and such Dim folderName As String = "C:" 'assign output folder to workpart folder folderName = Path.GetDirectoryName(workPart.FullPath) 'Msgbox(foldername) Dim fileNew1 As FileNew fileNew1 = theSession.Parts.FileNew() fileNew1.Application = FileNewApplication.Assemblies fileNew1.Units = Part.Units.Inches fileNew1.TemplateFileName = "Modeling\english-model-template_c.prt" fileNew1.NewFileName = foldername & "\" & Revcomp & ".prt" 'fileNew1.Application = FileNewApplication.Modeling fileNew1.MasterFileName = "" fileNew1.UseBlankTemplate = False fileNew1.MakeDisplayedPart = False Dim nXObject1 As NXObject ' 'nXObject1 = fileNew1.Commit() ' workPart = theSession.Parts.Work displayPart = theSession.Parts.Display fileNew1.Destroy() Dim sPartFullPath As String = theSession.Parts.Display.FullPath 'Dim part1 As Part = CType(theSession.Parts.FindObject(Revcomp), Part) Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0) Dim orientation1 As Matrix3x3 orientation1.Xx = 1.0 orientation1.Xy = 0.0 orientation1.Xz = 0.0 orientation1.Yx = 0.0 orientation1.Yy = 1.0 orientation1.Yz = 0.0 orientation1.Zx = 0.0 orientation1.Zy = 0.0 orientation1.Zz = 1.0 Dim partLoadStatus1 As PartLoadStatus Dim component1 As Assemblies.Component component1 = workPart.ComponentAssembly.AddMasterPartComponent(displayPart , "True" , Revcomp, basePoint1, orientation1, 50, partLoadStatus1) 'I wanted the component to be placed directely under the display part so I changed that, as well as part name and layer. End Sub End ModuleRE: Journal-wave link all visible bodies from all components
This journal only works once since it creates the component part both as a loaded part and a saved part. It is simple to add code to check for existing loaded part and/or existing saved part which if they exist can be used instead of creating new part.
Also note the line
Dim fullpathname1 As String = "C:\ugs\nx75\UGII\html_files\model_template_metric.prt"
which needs to be changed to suit your templates
CODE -->
Option Strict Off Imports System Imports System.IO Imports NXOpen Imports NXOpen.UF Imports NXOpen.Assemblies Module NXJournal Sub Main() Dim theUI As UI = UI.GetUI() Dim theSession As Session = Session.GetSession() Dim lw As ListingWindow = theSession.ListingWindow() Dim ufs As UFSession = UFSession.GetUFSession() Dim partname As String Dim workpart As Part = theSession.Parts.Work Dim disp_partname As String = Nothing Dim displayPart As Part = theSession.Parts.Display Dim comp As String Dim Revcomp As String Dim insert As String Dim partLoadStatus2 As NXOpen.PartLoadStatus = Nothing partname = Path.GetFileNameWithoutExtension(workpart.FullPath) comp = partname insert = "__Rev" Revcomp = partname & insert 'To find folder name and such Dim folderName As String = Path.GetDirectoryName(workpart.FullPath) Dim fullpathname1 As String = "C:\ugs\nx75\UGII\html_files\model_template_metric.prt" Dim fullpathname2 As String = folderName & "\" & Revcomp & ".prt" File.Copy(fullpathname1, fullpathname2) Dim basePart1 As BasePart = theSession.Parts.OpenBase(fullpathname2, partLoadStatus2) Dim part2 As Part = CType(basePart1, Part) Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0) Dim orientation1 As Matrix3x3 orientation1.Xx = 1.0 orientation1.Xy = 0.0 orientation1.Xz = 0.0 orientation1.Yx = 0.0 orientation1.Yy = 1.0 orientation1.Yz = 0.0 orientation1.Zx = 0.0 orientation1.Zy = 0.0 orientation1.Zz = 1.0 Dim component1 As Component = workpart.ComponentAssembly.AddComponent(part2, "Model", Revcomp, _ basePoint1, orientation1, 50, partLoadStatus2) End Sub Public Function GetUnloadOption(ByVal arg As String) As Integer Return CType(Session.LibraryUnloadOption.Immediately, Integer) End Function End ModuleFrank Swinkels
RE: Journal-wave link all visible bodies from all components
RE: Journal-wave link all visible bodies from all components
I can import the part and it will replace the new part I created but then that just creates a bigger problem.
If anyone can help me with this, I would really appreciate it. Thanks.