Jim, thank you for always helping me out. I thought I had the right syntax, perhpas some things don't have to be there.
Posts
-
RE: Beginner having issues with ends....need help
-
RE: Beginner having issues with ends....need help
I forgot to say thanks!
-
Beginner having issues with ends....need help
I've got a file with a number of nested if statements, and for loops. I've looked at it multiple times, but I cannot figure out what is wrong. It used to work before, but then I added some more statements and it either seems I have too many or too little, even though I was convinced I had just the exact amount.
It is a very short file. I am hoping someone better than me can quickly glance at it and see if they can tell whether or not I need more "ends" or less of them. I am starting to loose my mind.
-
RE: Question about position in space of an object
thanks! That seems to be what I need.
Bender
-
RE: Question about position in space of an object
Could you be a little bit more precise? I've looked in the transformation class, and see a method that returns the x-axis, y-axis and z-axis vector. I am just looking to get a certain entitie's coordinate. A function that returns it's 3d position.
-
Question about position in space of an object
I've been looking but couldn't find any method that can supply you with this information. If I add an object to my space, for example an object from the 3d warehouse, and I need to know its position in 3d space (ie, its coordinates (x, y, z) ), is there a method that does this for me? How can I do this?
I can't imagine there not being such a function. If I move an object to say (100, 200, 300) through the ruby console, that coordinate I assume should be somewhere present in the object's information. If anyone can help me I'd really appreciate it.
-
RE: Entities, how many is too many?
Hi. I forgot to add another simple question. If I have an entity object, say entities[0]...is there a way to retrieve that entities' present coordinates?
Something like: coordinate = entities[0].get_3dCoord
Is there such a method? How can I do this?
Thank you in advance!
-
Question about entities
I've placed this on the ruby forum, but realized this might be a better place?
I am working on an animation through the reading of a log file. As I am reading it, I am placing entities on the space in Sketchup. It starts off quite fast and gets progressively slower, until it is all very very slow. I am placing quite a bit of entities on the space, (100? maybe more). Is this too much? Is there a way around it? When placing the new object (entity), I use the add_instance method. What do you guys think?
Thank you as always. Benderbender
-
Entities, how many is too many?
I am still working on my animation through the reading of a log file. As I am reading it, I am placing entities on the space in Sketchup. It starts off quite fast and gets progressively slower, until it is all very very slow. I am placing quite a bit of entities on the space, (100? maybe more). Is this too much? Is there a way around it? When placing the new object (entity), I use the add_instance method. What do you guys think?
Thank you as always. Bender
-
RE: Using the Animation Interface, need some help, stuck
Solo: That is right. I'd like to move an object, while keeping the camera unmoved. (At least for now)
Jim: Thank you for that code. I've played around with it and was actually able to get it to work! For testing, I've been outputing the lines that I'm reading from the log file (there are about 6500 of them...). The only problem, however is that this task is VERY slow, and takes a very very long time to read and "animate" the log file, so it isn't much of an animation yet.
The example that I've looked at before moves the camera view around, and it actually is quite fast, but looking at the code, there doesn't seem to be anything to "set" the speed. Is there a way to increase the speed of this?
-
Using the Animation Interface, need some help, stuck
I've been playing around with the Animation interface, but am not getting anywhere. I very simply am reading a log file line by line, and would like to move an object by 3d coordinates.
The picture was as follows: Read one line, call a function that generates the visual and updates the object's position. This however does not work as the object does not move coordinate by coordinate, rather Sketchup moves it to the last coordianate read and so it does not appear to be moving.
I've been pointed in the direction of the Animaton Interface to fix this up. I've looked at the ruby file as an example and have played around with it, but I get the feeling that this is more something to do with the camera and point of view of the Sketchup model, and not a 3d object (although I may be wrong). I have not been able to do this for my situation here. I need someone to tell me what I am doing wrong and what I should be doing, if possible.
As it stands, I have a readLogFile method which does as it's called, and after each line calls "generateVisual" which should(but doesn't work) move the object. I then implemented the nextFrame method as required by the Animation interface, and set up the camera view (I don't really care about this, but I think it is necessary). Now, i also tried to update the object's coordinates through nextFrame rather than in generateVisual, however this did not work. I thought it would make sense to update the object's position through the nextFrame so that it would show it frame by frame...but not successful. Is nextFrame invoked by Sketchup automatically? How would I/can I solve this problem using the Animation interface, and if not what should I do/use instead?
I'm a little stuck. Thanks in advance
-
RE: Moving a 3D object by coordinate, through Ruby
Once the nextFrame method is implemented...(here I tried putting in the visual update) is it invoked by Sketchup automatically or does one need to make an explicit call somewhere in the code?
I'd like it to display a movement of the object by coordinate at a time, so I suppose if I consider that to be a frame, I'd define those movements within teh nextFrame method (which I did). But then, how is it called?
I'm still a little stuck on this. It's been sometime since I've programmed in Java as well. Anyway, please let me know if it is on the right track, or if I am doing something wrong.
Thanks,
Bender -
RE: Moving a 3D object by coordinate, through Ruby
I'm posting some code, might be more helpful:
def generateVisual(cell) puts cell #for testing model = Sketchup.active_model entities = model.active_entities cell2 = cell[cell.index(',')+1..cell.index(')')] num1 =cell[cell.index('(')+1..cell.index(',')-1].to_i num2 = cell2[0..cell2.index(',')-1].to_i num3 = cell2[cell2.index(',')+1..cell2.index(')')-1].to_i #puts num1 #puts num2 #puts num3 #puts " " #in the above 4 lines I've printed the 3 numbers to make sure that #it retrieves it properly from the file, and it does...so this cannot be an issue my_group = entities[0] #the one and only object there point = Geom;;Point3d.new num1,num2,num3 my_group.transformation = Geom;;Transformation.new point end
and basically whenever I read one line from the log file and retrieve a cell, I call this function sending the cell in, breaking it up into it's components and setting the object to that coordinate. However, it runs...and once it's done running, it THEN moves it to the last coordinate. As I've said before, I think it is doing it, but for some reason it does not appear in the visual...almost as though it is processing too fast.
Hopefully I can get some help from you rubyists. Thanks, Bender
-
RE: Moving a 3D object by coordinate, through Ruby
Jim,
Thanks for the follow-up. I've been able to move entities this way, and it works well. However, when I read a sequence of coordinates and attempt to move the object (entitie) at each coordinate, it doesn't do it. So, for example as a tester, I had an object which started at (0,0,0) and I wanted to move it to (10,10,10), then (20,20,20) and so on by incrememnts of ten until (100,100,100), but all it does is move it to (100,100,100). I think it DOES move it in between, you just don't see it...for some reason. Almost like the computer is too fast? -->so I added dummy for loops to "slow" it down, but this didn't seem to solve it. Any ideas on why it is doing this?
I am able to progress thanks to all the help here. Much appreciated. Bender
-
RE: Moving a 3D object by coordinate, through Ruby
Thanks for the reply, however from the code I basically see how to read a text file using a "," as a delimiter and storing each number into its respective variable, which I know how to do.
From the last line, I'm having some trouble:
my_group.translation = Geom::Transformation.new( [x, y, z] )
I've read on the Geom Class, and a few others, however I fail to see how this is doing or will do what I want. The closest thing I've found is to add an "entitie" and remove (erase_entitie) it, and do this continuously as I read the log file to replicate a sort of "movement."
What's my_group? Maybe if you could explain the last line. Anyhow, is my approach a good one? Or is there a better one. I am a beginner, so most things are still not yet clear to me.
Thanks again,
Bender -
Moving a 3D object by coordinate, through Ruby
I've posted this on the newbie forum, but since it is partly related to Ruby, I'm trying here as well.
What I have been trying to do for the last while is to read a log File through a Ruby script, through Sketchup of course. I've been successful at doing so, as I am able to see the output in the Ruby Console.
My goal, however is to be able to place a 3D object in Sketchup, and assign it a 3D coordinate from the log file as it is being read, which would translate into the object moving around in space. I haven't much of a clue on how to set this 3D object's coordinate, in order to be able to do what I've mentioned above.
I'll be adding this code to my Ruby script, under a method to generate this visual. Can anyone point me in the right direction? Please tell me this is possible...
Someone linked me to a plugin, but it had a discrete number of possible positions, where in my case the number of coordinates in the log file varies.
Thank you to all you Rubyists!
-
RE: Error when using "split()"
Thanks for the replies everyone.
-
RE: Moving objects with 3d coordinate
Thanks for the reply. I've taken a look at that plugin, but from my understanding it is very discrete in the sense that you can only "move" an object a discrete number of times through the use of the "transformations" option in the right click menu.
I however am reading a log file with possibly hundreds of coortdinates, and what I want to get from sketchup is a way to position a 3D object and set its coordinates as I am reading the log file. I mean, it should be quite simple to set its coordinates, then update them and get rid of the old ones etc...
Is there not a way to do this through the ruby script?
Thanks in advance.
-
RE: Moving objects with 3d coordinate
Just wondering if anyone's had a similar try with Sketchup, and if so how I go by doing it (through Ruby of course)
Thanks in advance
-
Moving objects with 3d coordinate
Hey all,
I have a log file that I need to read using ruby. From that log file, I generate a bunch of 3d coordinates. I know there is a 3D warehouse with an assortment of objects. Once I choose one (for example, a humanoid) how do I go about setting its coordinates?
My goal in the end is to be able to move it around using a set of coordinates (essentially looking like a small animation)
Your help is much appreciated! I am a newbie to all of this.