So, I get how to use parent as a variable way to reference the next level up in a component hierarchy, except it seems to fail (or I fail?) at the top component level, leaving no way to reference anything outside the component hierarchy. If I understand what you are saying correctly... to get a sort of "global" reference in a dynamic component, one must first place it in another component and work in that component. I guess I just figured the "right" way to have a hierarchy is to have a top level (being the model itself) and referencing model attributes vs component attributes at that point. This would seem to be the logical way to organize things to me. Though my attempts to produce any results in this way have all failed. Am I wrong in my understanding here?
Latest posts made by Skastafari
-
RE: Dynamic Component Value Reference Model Attribute Value
-
Dynamic Component Value Reference Model Attribute Value
Is this something that can be done? I have found myself in a situation where having a dynamic component value reference a model attribute value would be very beneficial; though I am not sure how, or if it can be done. If this can be done, can someone provide me with a working dynamic component syntax example. If this is not possible, I suppose I could accept the sad news instead.
-
RE: Excluding scenes from animation
I just found this...
https://forums.sketchup.com/t/handling-include-in-animation-flag-in-scenes/39368
I guess this is as close as I am going to get to the status of Dan's request.
-
RE: Excluding scenes from animation
Okay, I just learned a lot. So I gather that in order for a page to be excluded from the animation it would need parenthesis to wrap the label string, but when you create a page from the ruby API by default the name IS the label string so that explains why my idea did not work and also why when I uncheck Include in animation the tab name now has 2 sets of parenthesis. If it is true that we can not change the label from the API, then there really is no way I can achieve the function I need as far as I can tell.
I guess that is why Dan had put in this request back in the day:
https://forums.sketchup.com/t/ruby-sketchup-page-use-in-animation-use-in-animation/11020Thank you for your script and insights Tig. It was helpful to me. I do have a better understanding what is going on now.
-
Excluding scenes from animation
I am looking for a method to exclude pages from my animation similar to how the "Include in animation" checkbox works from within Sketchup's scene editor. I am generating multiple scenes that cannot be included in my final render, and find the extra step of checking each of those mixed in scenes to exclude them quite tedious. I am having trouble finding an example of how to achieve this in the API documentation. I noticed the parenthesis around scene names in animations and thought perhaps that was the indicator of an excluded scene, and it would be simply...
model = Sketchup.active_model view = model.active_view pages = model.pages #(define operation here e.g. view.camera.perspective = false etc.) status = pages.add "(excluded scene)"
However elegant this would seem, unfortunately it does not work. So I am guessing there is some other method to exclude scenes from the animation.
I had found a thread from Dan Rathbun somewhere dating a couple years back discussing a need for this, but I can't seem to find what the outcome was. If anyone knows, please advise.
-
RE: Need some development help.
Wow! okay. This is totally awesome. This is quite a few levels above what I am capable of writing. This may take me like a week just to figure out. Sdmitch, you have saved me hundreds of hours of treachery. I want to buy you a beer, but I think you deserve a whole keg. This is way better then what I was plugging away at. Tig had got me thinking in the right direction about what I was trying for better ideas, and I had a feeling bounds was the answer to locating the foobar. I changed line 65 to some regex (=~/^[Ff]oo/) I learned from Tig back in the day to solve for a couple foos that were made unique and I left out the selection bits. This should be the example to anyone trying to get components out of their parents and gathered into their own.
I want to thank the community here for being so awesome and living up to the name Sketchucation. I have learned so much from guys like Dan Rathbun, Thom Thom, TIG, sdmitch and too many others to list.
Thanks & Cheers! -
RE: Need some development help.
"I now see your issue.
There are several component definitions containing instances of the 'foo' definition."
Yes, getting the foo out of it's home, as to redefine its home without foos is equally important."When extracting a 'foo' instance it could cause that definition to vanish IF it's the only entity it had - is this anticipated..."
I had not anticipated this. I see, a foo removed from now empty container = nothing garbage collector. A foo should always be either in it's parent home, or possibly loose in the scene perhaps we must first gather all loose foos into their own parent component?"When extracting each 'foo' instance do you want to retain its current location within its current definition 'home' and replicate this within the 'new definition': then where does the instance of the 'new definition' need to go ?"
Yes, keeping it's current location in the world is very important. I do see the possible issue locating the new foobar component. It does seem like we need a reference to locate the foobar so as to maintain the foos in their current location. Possible to get a vector to origin from perhaps bounds to locate?TIG, I love how you make me feel like I am about to get "learned" from the schoolmaster master right now.
I included an example here of a very simplified but typical scenario I will need to solve thousands of times in the next 6 months or to eternity for all I know. I really appreciate the help. I am already thinking about this clearer than I was just a day ago.
-
RE: Need some development help.
Okay to be honest, I am not sure there really is a manual way to acheive this result easily, as it would require you to enter each parent container simultaneously. I struggled with the fact that in SU you must first enter into a component in order to select a subcomponent, however the act of entering or exiting a component resets your selection set. I will always prefer to spend my time learning something useful as opposed to doing something laborious. Which is why I came here. So here is what I have been doing to learn from sdmitch's example and here is how I understand it currently, though I may be wrong.
@mod = Sketchup.active_model [highlight=#ffff00:3b775s2t]Gets a handle on current model also saves tedious typing[/highlight:3b775s2t]
@ent = @mod.active_entities [highlight=#ffff00:3b775s2t]Gets a handle on entities currently in the model[/highlight:3b775s2t]
@sel = @mod.selection [highlight=#ffff00:3b775s2t]Targets entities within the current selection set, though I have to admit I left this out[/highlight:3b775s2t]
cntrs = @sel.grep(Sketchup::ComponentInstance) [highlight=#ffff00:3b775s2t]This iterates the components in the selection and I think it is here mostly to get into the parent components containers[/highlight:3b775s2t]
for cntr in cntrs [highlight=#ffff00:3b775s2t]Here some logic, I believe cntr is a placeholder for future transforms to objects returned from above iteration. The fact that it appears undefined makes me believe it is part of recursive process.[/highlight:3b775s2t]
cde=cntr.definition.entities [highlight=#ffff00:3b775s2t]I think this is both a shortcut and a way to define cntr without error to prepare for next line[/highlight:3b775s2t]
foos = cde.grep(Sketchup::ComponentInstance).select{|ci|ci.definition.name=='foo'} [highlight=#ffff00:3b775s2t]Where we find and grab all the foos with yet another iteration[/highlight:3b775s2t]
foos.each{|f|tr=cntr.transformation*f.transformation; [highlight=#ffff00:3b775s2t]This is where I start to get lost, or should I say go splat? I do understand this is where we get transform data from though.[/highlight:3b775s2t]
fb = @ent.add_instance(f.definition,tr); [highlight=#ffff00:3b775s2t]Here is where I start to have a problem, we do need to put the foos outside their original container and into a new container called foobar but...[/highlight:3b775s2t]
fb.definition.name='foobar' if Sketchup.version.to_i>=14 [highlight=#ffff00:3b775s2t]we are doing it from within foos.each which is how I think my foos got turned into foobars[/highlight:3b775s2t]
fb.definition.name='foobar'
f.erase! [highlight=#ffff00:3b775s2t]Here we just clean up the original foos, bang they are gone while simultaneously redefining the components they were in, very powerful and hugely time saving.[/highlight:3b775s2t]
}
endThen, I wrapped this in def fooBar so I could test and, I am way closer to a solution then I was on my own. I am very grateful for this help. Sorry I am not much use to others here in this forum, it is difficult for me to write when I am still just learning to read. This really is another language for me. If it takes me 30 days to finish this solution on my own, it will be better than spending 30 days clicking on component after component all day, and I will have learned a lot in the process. Thank you for your help everyone. Sorry if I am a bother.
-
RE: Need some development help.
Okay, awesome. Thank you sdmitch. This definitely opens some doors for me. I did have some unexpected results. I wanted to get the foos out of their homes and into the foobar (for some nightlife), but instead my foos turned into foobars. (I have a hard time typing this without laughing a little.) I see how you got the transform for the foos which is important to keep their location the same once in the foobar, but after that I got lost. I really just want my foobar to be populated with foos. If I get this right there should be just one foobar.
-
Need some development help.
I don't want to be a recursive idiot (though I am) and need some help solving a problem.
Problem is I have all these nested components and they are named foo.
I need to remove all component instances named foo from their parents and place them in their own new component named foobar. I had some embarrassing failures at this and it is clearly over my head. I can use some pro suggestions/solutions and I am thinking a ruby script is the way to go as I can hardly maintain my sanity doing this much work manually.