Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 Ah the for loop, atleast I understand that at this stage of learning int npts = npoints(0); for(int i=0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}) }; holycause, the above code is what you mean ? Quote Link to comment Share on other sites More sharing options...
holycause Posted April 4, 2016 Share Posted April 4, 2016 no, my bad. int npts = npoints(0); for(int i = 0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}); } Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 (edited) no, my bad. int npts = npoints(0); for(int i = 0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}); } What is it I should see as a result of the code ? Edited April 4, 2016 by Arthur Spooner Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 4, 2016 Share Posted April 4, 2016 If you want to use setattrib you need to use addattrib first if the attribute is not present on the geo. int npts = npoints(0); i@debug = npts; for( int i = 0; i<npts; i++ ){ addattrib(geoself(), "point", "Cd", {0,0,0}); setpointattrib(geoself(), "Cd", i, {1,0,0}); } Faster to do like this: int npts = npoints(0); i@debug = npts; for( int i = 0; i<npts; i++ ){ @Cd = {1,0,0}; } -b Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 Where can I find in the Houdini docs what the definition of npoints and npts is ? I still don't understand geoself() & geoself handle ? int npts = npoints(0); i@debug = npts; for( int i = 0; i<npts; i++ ){ @Cd = {1,0,0}; } Should the above code do something to a plane, torus or sphere ? Or is it strictly debugging, if it's strictly debugging, is there an debugging window in Houdini ? Quote Link to comment Share on other sites More sharing options...
bonsak Posted April 4, 2016 Share Posted April 4, 2016 You'll find all vex functions here: http://www.sidefx.com/docs/houdini15.0/vex/functions/_index -b Quote Link to comment Share on other sites More sharing options...
holycause Posted April 4, 2016 Share Posted April 4, 2016 based on your questions, I would highly recommend you to spend some time reading a little about coding, getting an introduction to it. you can read one here http://codingintro.com/chapter/en/1/introduction npts is just a random name I have chosen to use as a variable that will contain the results of the npoints() function. regarding geoself(), it points your function toward the geometry of the current node you're in. regarding your code, it would just set the Cd detail attribute npts times if you are in Detail mode. if you would run that in a point mode, the only part of your code you would need to set your Cd point attribute is @Cd = {1,0,0}; It's great you start to learn vex, but once again, spend time to understand the basics of programming, it will save you a lot of time. vex is using a similar syntax to any C language. Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 I searched the VEX functions dictionary, if I didn't find it in the VEX index dictionary, I should have known it was a variable, but I decided for clarification to ask regarding geoself(), it points your function toward the geometry of the current node you're in. In other words it points a function to the parent element; whatever the geometry is as the parent of the pointWrangler ? regarding your code, it would just set the Cd detail attribute npts times if you are in Detail mode. if you would run that in a point mode, the only part of your code you would need to set your Cd point attribute is When running the code in detail mode on a torus in pointWrangler, should I expect to see something in the viewport ? Quote Link to comment Share on other sites More sharing options...
holycause Posted April 4, 2016 Share Posted April 4, 2016 if you run your, no with mine, if you already have a Cd attribute on your input geo, then it will turn red. the setpointattrib works only on existing attributes. if the Cd attribute is missing, you can add this at the top of your code addpointattrib(geoself(), "Cd", {1,1,1}); the {1,1,1} represents the default value for the attribute you just added to your points. it also defines the attribute type: float, int. vector etc... Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 4, 2016 Author Share Posted April 4, 2016 if you run your, no with mine, if you already have a Cd attribute on your input geo, then it will turn red. the setpointattrib works only on existing attributes. if the Cd attribute is missing, you can add this at the top of your code Sorry I didn't understand ? Quote Link to comment Share on other sites More sharing options...
holycause Posted April 5, 2016 Share Posted April 5, 2016 your code: int npts = npoints(0); i@debug = npts; for( int i = 0; i<npts; i++ ){ @Cd = {1,0,0}; } you will not see anything different in the viewport with my code example: int npts = npoints(0); for(int i = 0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}); } If the Cd attribute doesn't exist on your geometry before the wrangle sop, you won't see anything in the viewport. If it exist (like if you have a Color sop before the wrangle) it will change the points color to red If you don't have the Cd attribute and want to add in your wrangle, your code should look like this: addpointattrib(geoself(), "Cd", {1,1,1}); int npts = npoints(0); for(int i = 0; i<npts;i++){ setpointattrib(geoself(), "Cd", i, {1,0,0}); } Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 5, 2016 Author Share Posted April 5, 2016 Returns the number of points in the input specified, or 0 if there is no input connected. How do you specify an input for the npoints function ? How do you have a color SOP before the wrangler ? I still don't understand what is geohandler, reading what specific VEX functions can do, as helped me understand what is posted. Quote Link to comment Share on other sites More sharing options...
Arthur Spooner Posted April 7, 2016 Author Share Posted April 7, 2016 I'm going to break up my questions into another thread; so it helps me and hopefully everyone else, keep my question threads to three pages maximum for clarity Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.