[Plugin] Cloud
-
Hi,
It should import the points quite quickly, but for triangulation: forget it (the delaunay algorithm is slow and SU is lazy when drawing such a bunch of new entities).
Regards, -
@didier bur said:
Hi,
It should import the points quite quickly, but for triangulation: forget it (the delaunay algorithm is slow and SU is lazy when drawing such a bunch of new entities).
Regards,Tried building the geometry with
fill_from_mesh
? -
Yes
-
ok great thanks for your quick response
-
Hello,
I have tried all of the Cloud_xx plugins into Sketchup 8 and I can't make any of them work. The file I am loading is very very simple. I will paste it below.I reverted all the way back to the very first Cloud_V6, the earliest that I could find, and the Ruby console says:
Error: #<TypeError: nil can't be coerced into Length>
(eval):151:in*' (eval):151:in
import_points_cloud'
(eval):144:ineach' (eval):144:in
import_points_cloud'
(eval):481
(eval):151:in `call'
(eval):151The file I am trying to load is:
1.000000,-0.003780
0.953817,-0.022681
0.907732,-0.040530
0.861844,-0.057373
0.816250,-0.073241
0.771049,-0.088146
0.726337,-0.102087
0.682209,-0.115043
0.638758,-0.126983
0.596079,-0.137864
0.554262,-0.147631
0.513396,-0.156226
0.473568,-0.163589
0.434864,-0.169660
0.397365,-0.174382
0.361153,-0.177706
0.326304,-0.179594
0.292893,-0.180019
0.260991,-0.178968
0.230666,-0.176444
0.201983,-0.172465
0.175003,-0.167064
0.149783,-0.160288
0.126378,-0.152200
0.104837,-0.142872
0.085206,-0.132385
0.067528,-0.120827
0.051839,-0.108290
0.038174,-0.094864
0.026562,-0.080638
0.017027,-0.065692
0.009590,-0.050101
0.004266,-0.033926
0.001067,-0.017214
0.000000,0.000000
0.001067025,0.017214296
0.004265824,0.033925754
0.009589569,0.050101133
0.0170269,0.065692279
0.026561946,0.080637625
0.038174357,0.094864216
0.051839352,0.108290174
0.067527771,0.120827496
0.085206132,0.132385097
0.104836709,0.142871957
0.126377609,0.152200267
0.149782864,0.160288431
0.175002525,0.167063819
0.201982773,0.172465155
0.230666029,0.176444437
0.260991083,0.178968318
0.292893219,0.180018886
0.326304356,0.179593805
0.361153194,0.177705805
0.397365364,0.174381539
0.434863586,0.169659848
0.473567837,0.16358949
0.513395521,0.15622643
0.554261644,0.147630793
0.596078995,0.137863597
0.638758334,0.126983409
0.68220858,0.115043056
0.72633701,0.102086543
0.77104945,0.088146303
0.816250482,0.07324092
0.861843645,0.05737344
0.907731641,0.040530362
0.953816541,0.022681392
1,0.00378which are the coordinates for a landing gear fairing. I have also appended ",0" to the lines in order to have a z-coordinate. I have also used the dialog box to tell the plugin that there is no Z data. Also have selected flattening (or not) in trying to make it work. Have tried every version of plug in from beginning to latest, no luck, will not work in any configuration. In one version of the plugin, it brings up a massive dialog box, so long that I cannot see the bottom, asking me to tell it which elements are which. I can never figure out how to see the bottom of the dialog box (I am amateur Mac user, there must be a way?), but there is no longer a "nothing" option, so I am not sure getting to the bottom would help me.
These are my questions:
- Do any of the Cloud plugins work in Sketchup 8?
- Is there something wrong with my data, and that is why the Cloud plugin is failing?
I am running Mac OS 10.5.8 on iMac Intel dual core with Sketchup 8.0.3161.
In responding, please keep in mind I don't know anything about Ruby. Thanks for your help.
-
Update:
I went back to verify that I had, in fact, tried every possible version on Mac. In the process of doing that, I found TIG's fixups, in these two posts:
latest: http://forums.sketchucation.com/viewtopic.php?f=79&t=24733#p240869
slightly earlier fixup: http://forums.sketchucation.com/viewtopic.php?f=79&t=24733#p212737I can't get either fixup to work in Mac in OS 10.5.8 and Sketchup 8.0.3161 as posted.
I jumped over to WinXP and Sketchup 7.0.10247 using the 'slightly earlier fixup' and was able to load my coordinates (attached PNG).
I saved this over to Mac and can keep working now, however, I would really like to be able to work only on the Mac.
I studied TIG's posts a bit and it seemed like the problem was some statements in the script that 1) were not portable from Win to Mac, and 2) were possibly non-standard usage of Sketchup API that might break the script in future versions. However, I also noticed some strange behavior on Mac that leads me to believe there is something wrong in the file handling of some sort.
When used on Mac with the file as shown, I get this error:
"More than 3 XYZ coordinates per line (139).
Please select X, Y, and Z in the following line sample."When I look at the line sample in the dialog box, it appears to show three coordinates, i.e., "1.000000,-0.003780,0" (note that I went back and added the extra ",0" just in case that was a problem - it wasn't). However, I can use the arrow keys and it turns out that a much larger part of the file is in the text box that shows the line sample. I can use the arrows to scroll around inside the tiny text box and see many other coordinates. I didn't think to see if the whole file were in that text box, but I did delete everything after the first line - but the same problem happens, the script simply will not process any data. I then get the same error as in my post above.
I have become convinced that the problem has something to do with how files are represented on the Mac versus Win. Is it possibly to do with CR/LF problems? Or something else wrong with my file?
Otherwise, I have found it extremely difficult to get any XYZ data into Sketchup, and not possible at all on the Mac (for me so far). It is very difficult to find the latest versions (I search for well over an hour to find TIG's fixups), to understand which ones have bugs and which ones not, etc etc. Even in the Plugin index there are four versions of Cloud_V6 referenced.
I am not able to sort out whether I have the wrong plugin or whether I am doing something wrong. Help is greatly appreciated, I have done everything I know how to do. Thanks.
-
Aerostreak
The links you gave refer to some tweaks I did to v6~.
This thread starts with v71.zip.
Have you downloaded that ??
That was fixed after I spotted a mistake in Didier Bur's coding of v70...
It works fine for me and other users on PC/MAC.
It's under Menu > File > Points Cloud > Import.
BUT the file MUST have 3 or more values per line separated by the specified character - e.g. ','
If you only have two it will return an error.
To add trailing zeros [,0] to the file you need to do some processing in a plain-text editor.
Do NOT use a word-processor - that will add hidden characters in the text and mess up big time.
Not sure what the MAC equivalent app' to Notepad++.exe is, but you need to ensure proper carriage-returns on line ends too - is there an option in the MAC text-editor for this ?
To edit the file in Ruby this one liner should do it - paste into the Ruby Console...filei="path_to_file/mypoints2.csv";filei="path_to_file/mypoints3.csv";;file=File.new(fileo, "w");IO.readlines(filei).each{|t|next if t=="\n";file.puts(t.gsub("\n",",0\n"));};file.close;
- edit it to replace
path_to_file
with the actual path to the folder containing the csv
the ..3.csv version has ,0 appended to each line...
- edit it to replace
-
TIG,
Thanks very much for your reply. I had previously tried the v71 zip file. At your suggestion, I re-downloaded it anew, placed into my plugins folder, and accessed it from the file menu as you indicated. I also used TextEdit on the Mac to edit the file to have three values per line as you indicate. TextEdit on the Mac usually edits in Rich Text Format (RTF); however, there is an option to switch to Plain Text, which I did before editing. I tried two versions of the file. In one version I had values separated by commas (and used the dialog to tell the script that). In another version, I separated values with semicolons as shown in all of the examples in the v71 folder. Both gave the exact same failure, see screenshot below.I have also tried saving the CSV file directly from Excel on the Mac. And also from Word on the Mac, where I had Word display only plain text. I also opened the file using two different programming editors on the Mac, NetBeans and Xcode. Both have 'plain text' editors that I use to write software. It doesn't matter what text editor I save the file from, it simply will not work. No matter what I do. I am an aerospace engineer and know my way around a computer, though I am only an amateur programming. Believe me when I say, I would not come to you unless I had exhausted every possible option that I could possibly find or conceive of. No joy. The one thing I have not done is use the Ruby statements you show below. I have no experience with Ruby and don't know how to do that yet, but I will go figure it out next.
In any case, attached are 1) the exact file I am trying to pull in using (now) Cloud v7.1 and 2) the screenshot of the result. This screen shot is taken as follows. I activate the Cloud plugin using File menu item. It brings up a dialog box to select the file, which I do. Then it brings up the dialog box asking for the delimiter. The last line of that dialog box (fourth line) shows the 'line example', and it is highlighted all in blue. I can scroll inside there using the arrow keys, and it appears there is a massive amount of data in there. Clearly, something is not reading the values correctly from the file, as if the program does not know where the end of the line is. When I hit return, I get the screenshot below: a dialog box asking me to pick the meaning for a long list of values. However, the dialog is off the bottom of the screen. I have discovered no way to view the bottom ('amateur Mac user'). I go ahead and hit return anyway, and script loads one point into the Sketchup drawing space. No other points are loaded. (By the way, earlier versions of the script had the option for 'Nothing' in the pick list for the attribute meanings - no longer an option for some reason, although, it currently doesn't matter as I can't see the bottom of the dialog.)
Others have had problems getting the Cloud plugins to work correctly. I have absolutely scoured their threads trying to find out what, exactly, they did to solve their problem and what, exactly, I am doing wrong. If the answer I need is in fact in those threads, I am completely missing it, if you or someone else could point out to me precisely my mistake I would be grateful.
I'm going to try three more things: a) type the file in by hand from scratch one more time into a guaranteed plain-text editor on Mac (probably Xcode) b) type the file in by hand from scratch on WinXP and move the file over to Mac before loading c) delete out the last [,0] on each line and process that [x,y] version with your Ruby script, which appears to look for '\n' explicitly. If you have any ideas at all please let me know, I am willing to try anything at this point (other than relenting to always loading skp files in WinXP and moving them over to Mac then copying into main drawing... ugh).
I'm out of ideas. Please advise. Thank you for your help.
-
I think it's something to do with the way your file has carriage-returns at the ends of lines etc ???
Can you post the actual file you have the big problem with... I'll look at it and re-post a 'fixed' version to see if it's any better...
Then we might be one step nearer a solution... -
TIG,
Thanks for quick reply. I found the problem, you were exactly right, problem was with Mac linefeeds. I posted the original file above, the link to it is dwarfed by the screenshot.I found the solution in Xcode. There is an editor option to convert the linefeeds on any file between Unix (LF), Mac (CR), and Win (CF/LF). Saving the file with either Unix or Win worked great - Cloud script worked in Sketchup exactly as advertised. Saving the file with Mac (CR) - failure.
Here is the screenshot of the fix, once I found the menu option I had the whole file loaded into Sketchup in less than 60 seconds.
Man alive, this trivial problem cost me probably six hours in total and about a week off the end of my life...
Thanks for your patience, I appreciate the help.
p.s. Seems like it might be worthwhile to mod the script to automatically fix this (i.e., to properly handle the Mac CR-only default), or, to provide a separate plugin that can pre-process input files for people before they try to load data with other plugins...
-
Hoo-bloody-ray!
Didier - you listening ?
I thought that Ruby's '\n' took any version of carriage-return appropriately ???
Weird.............
At least we have a 'fix'... -
Seems that CR in Ruby is "\r" while CRLF is "\n".
I've tweaked the script to check if lines end with CRLF or CR, and here's what I got from the file:
See new release at top of this thread.
-
Cool, thanks Didier. Your image is correct except I delete all the internal edges/faces and use only the outer edge. Next I am trying to learn how to loft multiple edges/curves in Sketchup.
I downloaded your new cloud_v8.rbs and tested it on my iMac. Sorry to be such a pest but unfortunately I believe it is broken. When I run the plugin, it goes immediately to selecting an origin for placing the point cloud, and never gives the dialog box to select the input file, etc. The plugin throws the following error to the Ruby console:
Error: #<TypeError: no implicit conversion from nil to integer>
(eval):252:in[]' (eval):252:in
initialize'
(eval):164:innew' (eval):164:in
endTool'
(eval):105:in `onLButtonUp'At first I thought I must have done something wrong, so I quit Sketchup, cleared out all plugins (completely empty plugins folder), downloaded a new copy of cloud_v8.zip, and put cloud_v8.rbs into the (now empty) plugins folder. This way I could guarantee that only Cloud plugin was installed. I started Sketchup again and verified that only Cloud_v8 available (i.e., no Plugins menu, and 'Points Cloud' option available via File menu). Unfortunately same result, plugin appears broken.
I am confident this is not a LF-CR-CR/LF problem as the script is never letting me pick a file. it goes straight to 'pick origin'. Just to be certain, I reverted back to cloud_v71.rbs as the only script in the plugins folder, and it works great on iMac (as long as I pick Unix LF or Win CR/LF as end-of-line, and do not pick Mac CR).
Sorry Didier but can you make another try at cloud_v8.zip? It would be nice to have it so as to avoid converting every file, etc. I will be happy to test for you.
Thanks for your support on this, I appreciate it.
-
@didier bur said:
:oops:
Seems that CR in Ruby is "\r" while CRLF is "\n".CR = \r
LF = \n
CRLF = \r\n (best compatibility between systems) -
It is common to use
.strip!
or.chomp!
on lines read from file. Either should take care of whitespace chars. This make the strings more consistent and less prone to comparison errors.chomp
will remove trailing whitespace from a String.strip
will remove both leading and trailing whitespace.whitespace is: spaces, tabs, \n, \r, and \r\n
-
Hi,
@unknownuser said:
Error: #<TypeError: no implicit conversion from nil to integer>
I see. Bug found (although the script works on my machine).
@unknownuser said:
When I run the plugin, it goes immediately to selecting an origin for placing the point cloud
Yes, this is normal. The updated PDF doc says it: "The first thing you'll have to do is click a point to set the points cloud origin".
Download the new version at top of the thread and replace the 'old' RBS file with the one in the archive.
Hope it will work now
-
Didier,
Thanks for the update, it works great. Well, almost. On my setup (Mac OS 10.5.8, Sketchup 8.0.3161) the plugin now handles files correctly with Unix (LF) ending and with Mac (CR) ending... but now it does not correctly handle Win (CR/LF) ending! I feel for you buddy, apparently Ruby is not so easy to coax into the desired behavior.Here is my report. I downloaded your latest plugin (cloud_v8a) and tested it as the only plugin. I tested Unix (LF) ending first - worked great. Then I tested Mac (CR) ending - worked great. I almost wasn't going to test Win (CR/LF) ending but thought for completeness that I should. So I did that and (if memory serves) it worked great. However, I just happened to click again in the window and the file box came up again. So I thought that the plugin was set up to load another point cloud without having to re-initiate the script (via file menu). So I thought, ok great, I'll do it again. However, the second load of the same file to a different location, and it only loaded one point (first point in the file). It would did not load the rest of the file. So I thought, hmm, maybe I should try this again. I selected another tool and drew a random shape, then re-selected cloud and it failed again to load, only loaded one point. On the plus side: in the past when it loaded only one point (or no points), the dialog box for assigning coordinates to data in the line would always be very long as in my previous post in this thread; however, that dialog is now always working correctly, i.e., the dialog box only has three coordinates even if the cloud does not load properly. Now here is the problem, I have to confess that I was not paying close attention when I tested CR/LF; and I am not certain that the first load worked correctly. I may be confusing that test with another.
So I quit and re-started Sketchup and tested each file ending again. I notice that for Unix and Mac endings, the script always works; however, it will not correctly load the point cloud a second time. In other words, to load multiple point clouds, it is required to select another tool (like the pointer) and restart the script via file menu. So I went and RTFM per your suggestion (lol, point taken) and the manual does not say whether the script should be 'looping' or whether it should end after the loading of the first point cloud that I could find. I've sort-of concluded that the second appearance of the file dialog box, resulting from clicking in the window after loading the first point cloud, is actually a minor defect? In any case it is not critical, it always worked to select another tool (like pointer), restart the script, and load a new point cloud.
So I could always very easily and quickly load multiple point clouds in Mac when the lines are terminated with Unix (LF) or Mac (CR). In that sense it is a great script and will be very useful on Mac now.
However, when continuing on to test Win (CR/LF) line termination on Mac, no joy. On all subsequent tests, I could not get the script to properly load the point cloud. I restarted Sketchup several times and re-verified the line endings via Xcode several times, no joy. It always loaded only the first point. So I am convinced that my memory is flawed, and that the first time I tested Win line ending (described above) I actually was testing Unix or Mac and didn't realize it; thus the first load would work, but not the second (as described). So I believe that Win endings on Mac machines are not working in this latest cloud_v8a version. Now on one of the tests when it loaded only one point, I did happen to select 'triangularize' the point cloud, with the following result:
which I found a bit odd, since there is only one construction point, but clearly the script thinks there are other points not at the origin, which do not have construction points, and which do not match data in the file (i.e., compare to pictures of correct loadings in your previous post). I don't think this is a major problem since the script isn't loading the data correctly in this case to begin with, however I describe this here in case it provides any additional clues for troubleshooting purposes.Apologies for yet another long post, I know this must be frustrating. I am trying to describe what is happening in as much detail as possible and as accurately as possible to help you find any problems. If it would help for me to post a video of me doing the testing, please let me know and I will try that also, maybe I am making a mistake somewhere and you will then be able to see it.
Conclusion, the script is working great on Mac now with the one exception, a Mac user attempting to load a point cloud file originating from Win (with CR/LF in it) will not work. Some people may be able to fix it on their own, more inexperienced users may not.
In any case the best option for a Mac user needing to load a point cloud is Cloud_v8a.
Thanks for your continued effort, I am using the plugin heavily and appreciate it.
-
Weird...
So v8b is here.
Hope it will work in all cases now, although v8a was working with CRLF line endings here. -
Thx for the update Didier.
Ben
-
Success with all line endings!
Thanks Didier!
Advertisement