C++ or Python Journal
C++ or Python Journal
(OP)
Hi
I want to be able to create a journal that creates a Surface through points by importing an external .dat file. I can do it via a macro, but wondered if anyone would be able to help with a journal.
Insert Surface through points
Select points file (.dat) from a specified folder (my documents)
OK
Surface created.
Many thanks in advance, I have attached a points file as an example.
I want to be able to create a journal that creates a Surface through points by importing an external .dat file. I can do it via a macro, but wondered if anyone would be able to help with a journal.
Insert Surface through points
Select points file (.dat) from a specified folder (my documents)
OK
Surface created.
Many thanks in advance, I have attached a points file as an example.
Best regards
Simon
NX7.5 NX8.5 NX9 NX10
NX Consultant
www.team-eng.com





RE: C++ or Python Journal
Also, I see 4 versions of NX listed in your signature. Which version will this journal be for?
www.nxjournaling.com
RE: C++ or Python Journal
Yes, the dialog box looks the same always, we are using NX10. We are actually trying to run the journal from outside NX if that makes sense, without using the NX GUI.
Best regards
Simon
NX7.5 NX8.5 NX9 NX10
NX Consultant
www.team-eng.com
RE: C++ or Python Journal
I would be quite careful with this, there is no tolerance on this feature, I have seen examples where the resulting surface was , "useless".
( it had 1200 x 1200 patches and was as smooth as sandpaper...)
I.e if you feed it with many points, the result becomes heavy . and wavy.
Regards,
Tomas
RE: C++ or Python Journal
CODE
import NXOpen import NXOpen.UF theSession = NXOpen.Session.GetSession() theLw = theSession.ListingWindow theUfSession = NXOpen.UF.UFSession.GetUFSession() def isBlank (myString): if myString and myString.strip(): #myString is not None AND myString is not empty or blank return False #myString is None OR myString is empty or blank return True def main(): workPart = theSession.Parts.Work displayPart = theSession.Parts.Display markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "surface thru points") theLw.Open() #input file with row and point data fname = "C:\\temp\\input_data.dat" with open(fname) as f: content = f.readlines() # initialize list to hold row information rowInfo = [] for x in content: #theLw.WriteLine(x) # skip any blank lines if isBlank(x): continue if x.strip().upper() == "ROW": # append an empty list to use for the next row point data rowInfo.append([]) # nothing else to do for a ROW entry continue # get last entry in rowInfo list (the list of point information for the row) ptInfo = rowInfo[-1] # point data is three float values separated by spaces try: pt = x.strip().split() for item in pt: ptInfo.append(float(item)) except: # skip this entry, move to next continue # debug ''' for x in rowInfo: str1 = ''.join(str(e) for e in x) theLw.WriteLine(str1) ''' bSurfInfo = [] for x in rowInfo: temp = NXOpen.UF.Modl.BsurfRowInfo() temp.NumPoints = len(x)//3 temp.Points = x temp.Weight = [1.0 for n in range(len(x)//3)] bSurfInfo.append(temp) #theLw.WriteLine("number of points: " + str(len(x))) #theLw.WriteLine("bSurfInfo length: " + str(len(bSurfInfo))) surfTag = NXOpen.UF.Tag() surfTag = theUfSession.ModlGeneral.CreateBsurfThruPts(1,0,0,3,3,len(bSurfInfo),bSurfInfo) theLw.Close() if __name__ == '__main__': main()www.nxjournaling.com
RE: C++ or Python Journal
Best regards
Simon
NX7.5 NX8.5 NX9 NX10
NX Consultant
www.team-eng.com
RE: C++ or Python Journal
of curiosity,: Why Python ?
Regards,
Tomas
RE: C++ or Python Journal
www.nxjournaling.com
RE: C++ or Python Journal
the title.
that little detail...
RE: C++ or Python Journal
NX8.5 - NX9 - NX 10 - NX11
RE: C++ or Python Journal
www.nxjournaling.com
RE: C++ or Python Journal
NX8.5 - NX9 - NX 10 - NX11
RE: C++ or Python Journal
www.nxjournaling.com
RE: C++ or Python Journal
NX8.5 - NX9 - NX 10 - NX11
RE: C++ or Python Journal
RE: C++ or Python Journal
anyway thanks :)
NX8.5 - NX9 - NX 10 - NX11
RE: C++ or Python Journal
For the record, NX uses VB.net, not VBA. Either one has the power to get the job done; to say that one is more powerful than the other is largely a matter of personal preference.
www.nxjournaling.com