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?
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. -
RE: Help getting Parallel Projection in current view from Ruby
Thanks thomthom, you never let me down.
-
Help getting Parallel Projection in current view from Ruby
I am currently tangled in a web of Camera/View/Page classes and need a working example of how to get parallel projection enabled in the current view from the Ruby console. I feel like View can be defined as what I am looking at on the screen currently, while Page is the saved Sketchup scene, and Camera seems to be how the view is displayed, fov etc. I can't seem to come up with a good method of showing parallel projection in the view. I tried setting fov to 0, it did not like that. I tried setting camera perspective to false, it likes that, but did not change the current view any. I am sure I am missing something here. It seem like a camera change should affect the current view, but found that is not the case. I found many ways not to view parallel projection, could use a snippet showing how.
This is what I have that is working...
model = Sketchup.active_model view = model.active_view pages = model.pages pages.selected_page = model.pages[0]#Uses Scene 1 to be parallel projected #Need method for parallel projection here, nothing I have come up with works yet. view.zoom_extents status = pages.add "Scene1_Parallel_Projected"
-
RE: Help hiding groups and components from Ruby prompt.
Heh, I opened that can of worms and closed it real quick. I went to an array from a list of model names to hide. I am much happier this way. Thanks
-
RE: Help hiding groups and components from Ruby prompt.
Thanks ThomThom,
I am quickly realizing that messing with component attributes is a pain in the arse, especially dynamic ones. I will probably rethink this idea a bit. -
Help hiding groups and components from Ruby prompt.
I need to setup a method of hiding certain objects in my scene from ruby command. Said items might be groups or components. I would like to add a custom attribute named "HideThis" to all my models (groups/components) and give it a value either 0 or 1, 1 would be equal to hidden. I was thinking I could grep my active entities and check for HideThis=1, if true then .hidden=true... something like that. That is my idea, I could use some help with syntax/method making that happen. I have no idea as to how to access custom attribute values from ruby. Any direction would be appreciated. Thanks in advance.
-
RE: Problem with imported geometry.
Yeah, Jim's was kind of ground breaking for the day. I liked Tig's rework with textures, but I still had enough mesh trouble to make it not worth the trouble. I am importing whole house floor plans, and need groups to come in correctly to sort fixtures and the like. This is fairly large scale, over a hundred a week. I don't have a lot of room for error. SimLab offered groups, but when exploded, they turn to components named geom or something. I can easily end up with 70,000 plus unwanted component definitions, so no go with the long purge times. I had a custom build of fluid importer, but it is no longer supported. It looks like fluid obj importer might have a pro version coming out, so I might go that route instead. Thanks
-
RE: Problem with imported geometry.
Honestly John, it is not going to matter. I was trying to get useful geometry from Simlab's OBJ importer, but I am afraid I may have to drop it like a bad habit. There are other issues like the creation of tens of thousands of component definitions that emerge when groups are exploded. I do appreciate all the help I have got here. Thanks for making this community so awesome.
-
RE: Problem with imported geometry.
It's okay John, The result was the same... 8-10 minutes of beach ball followed by either my desired result or a bug splat; toss a coin. What is this used for in API ?..
smooth_flags = Geom::PolygonMesh::NO_SMOOTH_OR_HIDE
Is there a way to use this setting on a array? -
RE: Problem with imported geometry.
I tried using an array similar to how John suggested, but get no method error on smooth=, I am not sure what causes that. If I undo the the explode, sure It gets rid of the smooth, hide, & soft, but it also brings back the group I don't want. What I really want is to explode with the smooth, hide etc. set to false. It seems like it is on by default? I tried 2016 and got the same problem. The geometry is coming from an OBJ file using Simlab importer. The method I have works, but takes too long and is too unstable to use productively. I have a lot of models to process. I do appreciate the help any other ideas?
-
Problem with imported geometry.
I am having an issue with some imported geometry.
When exploded down, my models faces combine to form a surface with smoothed rounded edges.
I don't want this.I tried this...
entities.grep(Sketchup::Edge).each{|e| e.smooth=false;e.soft=false;e.hidden=false }
But the above takes a long time and often crashes SU.I found this in the API...
smooth_flags = Geom::PolygonMesh::NO_SMOOTH_OR_HIDE
It looks like something added for 2014 release?
I am trying to figure out how I can apply this to my exploded geometry, if at all.
Any possible solution would be appreciated.