@unknownuser said:
Aha, you mislead us somewhat by not stating your real question at first!
Indeed.
I think Slbaumgartner wraps it up pretty nicely.
@unknownuser said:
Aha, you mislead us somewhat by not stating your real question at first!
Indeed.
I think Slbaumgartner wraps it up pretty nicely.
A, what the heck. Here some very simple code suggestion. I don't know if it's this you want to do.
Sure this can be implemented by math calculations. But using vectors and points + maybe adding length.class assures you'll be within Sketchup tolerance..
I'll probably do different if communicating with exterior program. But always convert to Point3d objects.
prompts = ["length", "Run","height","Rise","Total Rises"]
defaults = [36.0,10.0,1.0,7.75,7]
input = UI.inputbox prompts, defaults, "Tread."
len, run, heit, rise, n_steps = input #len(a) not used in original ?
ent = Sketchup.active_model.entities
# Assuming height is meant startdistance under ORIGIN
pts = []
v_rise = Geom;;Vector3d.new(0,0,rise)
v_run = Geom;;Vector3d.new(0,run,0)
startpoint = Geom;;Point3d.new(0,0,-heit).offset!(v_rise.reverse)
p1 = startpoint.offset(v_run)
pts << p1
pts << startpoint
for i in (0...n_steps)
pts << startpoint = startpoint.offset(v_rise)
pts << startpoint = startpoint.offset(v_run)
end
pts << startpoint.offset(v_rise.reverse)
f = ent.add_face(pts)
f.pushpull(20)
I don't have time for code, but I drew this quick idea..
Shouldent be to difficult to figure out vectors and loop points..
Be careful doing mathcalculations to use Point3d ojects so the floats don't hose you out of sketchup tolerance..
Ah, doh. I missread. You want an edge, not an infinite line.
Do you really need to edit both z-values? I thought the vector was static in the equation..
I'm confused Try different y values on pt and test if the line is not straight..
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
a = -50
b = [[0,0,a],[0,50,0]]
pt = Geom;;Point3d.new(10,999,0)
pt2 = pt.project_to_line(b)
ent.add_cpoint(pt2)
Below ? In Z-axis you mean.
Well the first value is a point so maybe try [[0,0,-dist], [0,30,40]]
@unknownuser said:
Thanks,
I'm just trying to find a way not to have to keep pressing 'Ctrl & "A" then delete, every time I want to test a code.
Ah, right! Understood.
Well TT and Driven got the answers already.
Another handy plugin is using Alex Ruby-code editor.
You don't have to wrap code in Start Operation cause there's an inbuilt Play and Undo button. Very useful for testing loose code snippets. Copy and paste from Notepad for ex..
One idea is starting using groups to organize your geometry.
Clearing everything on the screen, sounds like a dangerous approach to me.
Just a simple tip..
ents = Sketchup.active_model.entities
gp = ents.add_group
ent = gp.entities
I'm guessing this has to do with lack of meta tags in the HTML head.
Try something like content="IE=edge" or similar depending on your target.
You can do a search on META-tag for details, it has been taken up in earlier topics.
Or here:
Anything that kills "weed" is determined to get banned in the Netherlands.
Try to do that for 8 hours a day for 2 months and see what kind of tendonitis gets developed...
Not sure if this will be of any help, 2dboolean.
(It's free so you can have a look at no expense, and see if it's useful)
http://sketchucation.com/forums/viewtopic.php?p=350557#p350557
Could be used not only for fitting 2d components to a face, but also in the creation of extruded sheet metals for walls etc. Or any other pattern you can come up with.
(manual is on same page)
I get the same behavior as you, with your file.
Cannot reproduce it by creating my own project.
Funny thing, if you explode and regroup, the behavior continues.
If you explore the nested affected group it has Parent: #Sketchup::ComponentDefinition:0xfa0aba4
The parent group's Parent = #Sketchup::Model:0xb4c150c
So there appears to be some hiearchy problems perhaps, unless I'm reading the
values wrong.
Have you copied and pasted in a group into the parent group, per chance ?
@unknownuser said:
I can't speak for WXwidgets, not familiar with it. Though I seem to recall some issues where they changed the order the window hierarchy - but maybe that was just the Ruby wrapper, I don't know.
I think it was the Ruby wrapper that was causing problems.
The posts touching the subjects are very old, as mentioned..
@unknownuser said:
But in general you can use whatever C/C++ lib you want. Native dialogs, knock yourself out. I haven't done so myself yet, but I wanted to try out a simple hello world window once.
I have done some code that calls the system folder picking dialogs though. Works very well.
I thought it was a no go on that! I'll peek around a little then.
Report back if I find something exiting.
Thanks
@unknownuser said:
That's a Ruby world optimization - because creating Ruby objects are expensive.
Not the same in C++.
Ok understood. It's quite wierd comming from Ruby to C++.
@unknownuser said:
So now you're getting the correct array size?
Yes. And the code work's as I wanted to So far anyway. Really fast.
I included your MACRO just to be safe. The code worked compiled in SU8.
I imagine I could even make it faster refactoring it. But.. Most importantly I want it to be proper, so I try to follow your advice and read up on best practices before I move on.
On another different subject while we are at it. Probably should start a new topic, but it doesent fell improper to ask here as well.
Can we use Windows forms or WXwidgets(not WX-rubyversion) or other GUI toolkit with c++ in Sketchup ?
I've seen discussion about it, but it was long time ago and relevant to only Ruby.
I've seen examples where they hook up MFC as resource to win32 projects. Also read here somewhere it can be problematic to hook that up to Sketchup window, since windialogs are under the desktop(?)
Anyway, not an substitute for webdialogs, just could be handy for some simpler dialogs using visual studio dialog editor.
Well well. How dumb can one get seriously
Have been copying and pasting in code from Notepad++ to sketchup ruby code editor.
Totally unfocused on that part..
At some point I must have pushed ctrl v instead of ctrl c, so I not noingly had duplicate code.
Off course I wasent editing the first part that was sent in to Visual studio for step over.
Hehum, thanks for the help Thomthom. All is not lost. You have provided some good information for the rest of us and I learned some new stuff
I meant hoisting variables before running loops. Speeding up the loops by not declaring them inside the loop.
Changing to rb_funcall(curve, rb_intern("get_points"), 0); made no difference, so I will try that other macro you mentioned. Otherwise there must be some hole in my logic elsewhere..
PS: I havent come to best practices part yet
Thanks for the help.
I am doing a C++ extension, yes.
@unknownuser said:
rb_intern returns ID, not VALUE
Well that changes things. That could be it. Will test that in various combinations and report back.
So would the syntaxrb_funcall(rb_intern("get_points")etc... be better then instead of storing it ?
@unknownuser said:
try to reproduce in a small standalone case.
I have created a smallish testcase. Although I needed some classes for that.
So the code become over 500 lines.
I run that code in Alex ruby code editor while debug. Don't know if that can affect the scope of class or anything.
And I have tested the data before sending in to c-extension, it's alright in Ruby.
The C++ code may very well have logic errors I havent found yet. So I have to scan that through again. It looks like this is the main problem though, since I'm dependent of array length for next iterations. When all the arrays(curves) have same length code is working.
@unknownuser said:
That's very old C syntax. Even newer C syntax allow you to declare variables when you need them.
I couldent tell whats proper syntax or not, yet. That does sound easier.
Does that go for loops/iterators as well?
Ahhh. A solution perhaps
I'm running Sketchup 2013 in debug mode. So it should be running Ruby 1.8.6 though ?
This has been a very annoying problem to solve. I'm clueless.
There's no error but irratic behavior with wrong values which makes it hard to track.
I was thinking it had something to do with me calling instance method from a class
sort of thing. The "curve" is an instance from a class I created and not a Sketchup curve, but I assume you got that part.
I suppose I could make the Ruby array an accessor and then use instance var get, but I rather not.
Will try your code when I get to my workstation later.
Thanks!