Text , X , Y , Z import
-
Hi , I have been googling after a Text , X , Y , Z import plugins for days now . Does any body know of one?
I have found a Point cloud importer but I need the point name as well.
And when im trying to import a DXF or DWG the sketchup allways skips Text.Regards
Kristoffer -
Because SUp is a '3D modeler' the 'text' in any imported DXF files etc is considered unimportant and so it is ignored by the standard Pro Importer tools.
Therefore I wrote a tool that imports any text from a DXF file as 'flat' 3D text - with string, font, size, color, layer etc kept from the file...
See here http://forums.sketchucation.com/viewtopic.php?p=194488#p194488
It's not perfect, but it does 'work'.
Please read the notes first... you'll need to import the points then the text from a DXF with the origin retained the same in both -
Also if you have a text file with points AND related 'text' in it, then I could look at an example and perhaps advise how you might extract the text-notes into your model as well as the points... Please post an example file...
-
Hi , I have added an example file.
Im doing a lot of reverse 3d engineering and when I have a lot of points to import it`s prity hard to manage with out the "point id" text.
Hope the example is helpfull
Thanks for you help so farBest regards Kristoffer
-
By the way , The file is a Ascii .DAT file
Ragards
KRistoffer -
And what unit is the data in?
-
The unit is in millimeters.
Regards Kristoffer
-
Try this... copy/paste code into a file called
cptstxt.rb
in Plugins.=begin To run type 'cptstxt' into the Ruby Console... =end require 'sketchup.rb' def cptstxt() model=Sketchup.active_model ents=model.active_entities layers=model.layers lay=layers.add("CPTS") vec=[1,1,1]## change this to alter text-location/leader-length file=UI.openpanel("Select the DAT File...","*.dat") return nil if not file model.start_operation("cpointstxt") text=IO.readlines(file) 0.upto(text.length-1) do |i| line=text[i] line.strip! if line line.chomp! if line data=line.split(",") next if not data[3] txt=data[0] x=data[1].to_f.mm y=data[2].to_f.mm z=data[3].to_f.mm pt=[x,y,z] cp=ents.add_cpoint(pt) cp.layer=lay tx=ents.add_text(txt,pt,vec) tx.layer=lay end#do model.commit_operation end ###
-
Hi
I cant get it to work properly , I only get this error message from the ruby console, And I get some errors when starting up SketchUpcptstxt
Error: #<NameError: (eval):894: undefined local variable or method `cptstxt' for main:Object>
(eval):894Your script says " require 'sketchup.rb' "
Does that mean that I have to copy/paste the file from the "tools" folder and into the "plugin" folder?Regards
Kristoffer -
Hi , I managed to fix it
It was just missing the "#" on the 3 first linesThe plugin works perfect Thank you so mutch for your help .
Best regards'
Kristoffer -
You need to 'select all' and copy/paste it - you must have missed something off ?
The=begin...=end
is the same as putting#
at the start of each line - these are 'comments', not read by the Ruby interpreter. As there's only one line of 'comments' I could have omitted the=begin
and=end
lines completely and put a#
at the start of the line of instructions - it'd been simpler! I just made the script from my own template that already has that format in it as multiple lines of comments/notes are often needed...
Do not movesketchup.rb
from the Tools folder. It loads automatically from there.
It is good practice to add the linerequire 'sketchup.rb'
at the start - most scripts need Sketchup's functions to run and will report an error if they load before it does; the 'require
' waits for the specified file to load first... It's an instruction to the Ruby interpreter, not you !
Glad it's working - did you notice that you can adjust the location of the text and leader length by playing with thevec=[1,1,1]
numbers ?
-
Hi , Thanks for the Text and Leader tip
If I want to import Y, X ,Z rather than X,Y,Z
Can I just switch around the
x=data[1].to_f.mm
y=data[2].to_f.mm
z=data[3].to_f.mm
pt=[x,y,z]To
y=data[1].to_f.mm
x=data[2].to_f.mm
z=data[3].to_f.mm
pt=[y,x,z]Best Regards
Kristoffer -
Yes.
Thedata[]
order is the order typed in each line in the .dat file.
The original code assumed the first was the 'text', then x, y and z values, as in the .dat file supplied.
You can have the .dat file's entries in any order as long as the code's data[] values are adjusted accordingly - for example if the format werex,y,z,text
then the values would all change around to suit withtxt=data[3]
, and thenx=data[0]
,y=data[1]
andz=data[2]
...
The code I gave you was only a basis for .dat file reading - it's very flexible...PS: DON'T swap the point's values around use
pt[x,y,z]
always, no matter what the order they were read from the file ! -
Hi again
When I try to import a file Negative Co-ordinates I cet an error
Is this an easy fix ?See the example file
Best Regards
Kristoffer
-
What's the error ? Please post examples...
The codex.to_f.mm
should take the text 'string' of 'x' and make it into a 'number' [+/-] and then tell SUp it's in 'mm', not the default 'inches'? -
@khallgren said:
When I try to import a file Negative Co-ordinates I cet an error
Exactly what does the error say?
-
Hi , I tried to make my own file for testing and the negative co-ordinates workes fine, so the problem is not the negative co-ordinates. But when I export a file from my calculation program and try it import it I get an error, but the files sceems identical to me?
Here is the error i get
and the file is attached below
Error: #<Errno::ENOENT: C:/Programfiler/Google/Google SketchUp 7/Plugins/cptstxt.rb:14:in `readlines': No such file or directory - C:\Documents and Settings\krh\Skrivebord\BeregnetHøyderfile8.txt>
C:/Programfiler/Google/Google SketchUp 7/Plugins/cptstxt.rb:14Best Regards
KRistoffer
-
I think I know what the problem is . Its the dicimales.... Its fine importing a file that says:
example: text,200.0,200.0,200.0
But when the file has a desimale value thats larger than 0 i get an error
example: text,200.5,200.5,200.5
Best regards
Kristoffer -
Ah!
I know why that is - because you are Norwegian! Sketchup's ruby doesn't read files that has characters which isn't ASCII (A-Z). So our beloved æøå makes SU's file functions go belly up.I struggled for ages with this some time ago. Found no good solution for that. You can work around be renaming your file.
Hilsen fra Bartehovedstaden!
-
@khallgren said:
I think I know what the problem is . Its the dicimales.... Its fine importing a file that says:
example: text,200.0,200.0,200.0
But when the file has a desimale value thats larger than 0 i get an error
example: text,200.5,200.5,200.5
Best regards
Kristoffer?? With the same file you tried earlier? Or did you create a new test file with just ASCII chars in the file name & path?
Advertisement