Sloader Posted August 3, 2021 Share Posted August 3, 2021 I am importing XYZ survey data and null data points are set to -9999. I need to delete these null data points (Loci with a Z value of -9999) I have managed to get this working for small areas of data using ForEachObject and checking the ZCoordinate but it's too slow for big sections. Any other approaches that might be quicker? nulv = int("-900") def deletenulls(h): HeightValue = vs.ZCoordinate("T=LOCUS3D") if HeightValue < nulv: vs.DelObject(h) vs.ForEachObject(deletenulls,"T=LOCUS3D") Quote Link to comment
Pat Stanford Posted August 3, 2021 Share Posted August 3, 2021 ZCoordinate is returning the Z for every 3DLocus so you are actually doing the criteria search N+1 times. Also, it is probably faster to do the delete once rather than in the loop. The following will deselect everything in the drawing and then select jus the 3DLoci that are below the MyZ constant value. I will leave the conversion from Vectorscript to Python and adding the delete step to you. Something like vs.deleteobjs Procedure Test; Const MyZ=-2; Procedure Execute(Hd1:Handle); Var X1,Y1,Z1:Real; Begin GetLocus3D(Hd1,X1,Y1,Z1); If Z1 < MyZ then SetSelect(Hd1); End; Begin DSelectAll; ForEachObject(Execute, ((T=LOCUS3D))); End; Run(Test); 1 Quote Link to comment
Sloader Posted August 4, 2021 Author Share Posted August 4, 2021 Cheers Pat! GetLocus3D is much better for what I want, I use the wiki to search for functions but it's easy to miss useful ones. As far as I can tell (and I may be wrong) with Python GetLocus3D returns a tuple rather than individual parameters so I have to extract Z value. I could have used your Vectorscript but learning some Python is hopefully a by product of automating some things in vectorworks. The code below seems to work vs.DSelectAll() MyZ = -100 def Execute(h): TupXYZ = vs.GetLocus3D(h) pZ = TupXYZ[2] if pZ < MyZ: vs.SetSelect(h) vs.ForEachObject(Execute,"T=LOCUS3D") vs.DeleteObjs() 1 Quote Link to comment
Pat Stanford Posted August 4, 2021 Share Posted August 4, 2021 I only gave us VS because I have not take then time to learn Python (and probably won't unless I have to as "me hates white space delimiting"). But if it works for you more power to you. Glad to help. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.