I'm noob in script but good in animation, I need some help to create a script selection.
I found an exemple :
import maya.cmds as cmds
# Get selected objects
curSel = maya.cmds.ls(sl=True)
# Or, you can also specify a type in the listRelatives command
nurbsNodes = maya.cmds.listRelatives(curSel, allDescendents=True, noIntermediate=True, fullPath=True, type="nurbsCurve", path=True)
cmds.select(nurbsNodes)
But It doesn't select all the character's controlers...
I would like If I select a character controler curve or locator and I run the script, the result is all controls who can be keyed should be selected. Without the referenced character name.
Thanks a lot for the one who can help
Currently the listRelatives command is being used to list all child nodes under the currently selected transforms, whose type is a NURBS Curve, e.g. type="nurbsCurve". Typically all nodes in Maya inherit from some other node type (It's worth checking the nodes in Maya help -> technical documents ->nodes). Luckily locator nodes and curves both inherit from 'geometryShape', so you should be able to replace "nurbsCurve" with "geometryShape", and that will probably get you most of the way there. You may need to ignore certain returned nodes though - i.e. polygonal meshes you are using for rendering.
Related
In YAML, we are not allowed to assign an alias to an anchor. How can I acheieve similar functionality so that I can use one generic key throughout the YAML file while only needing to make an update in one location?
t_shirt_sizes:
&t_shirt_xs EXTRA_SMALL
&t_shirt_sm SMALL
&t_shirt_md MEDIUM
&t_shirt_lg LARGE
&t_shirt_xl EXTRA_LARGE
t_shirt:
&t_shirt_size *t_shirt_md
# Use the *t_shirt_size further down the YAML file
store:
order_shirt_sizes: *t_shirt_size
This is possible:
t_shirt:
&t_shirt_size EXTRA_SMALL
It fulfils your requirement to only need a single change to change the size everywhere. If you need the indirection, the closest thing you can do is
t_shirt:
&t_shirt_size [ *t_shirt_md ]
Then you'd need to handle the size value as 1-value sequence during loading.
YAML serializes a graph of directed nodes. Using an alias makes another connection to the referenced node, therefore does not create a new node and thus it cannot be anchored. The purpose of anchors & aliases is to be able to serialize cyclic graphs.
I am new to Sketchup Ruby and am blown away this is not more simple but here goes...
I would like to copy all the groups matching a certain layer name to a new temporary group. I have basically given up on trying to copy the whole group because that appears to be fraught with peril and Bugsplats if not done in some super-anal retentive way that considers context, immediate exploding of objects, etc...
So, I have resorted to trying to loop through all matching groups entities and copying faces instead, which seems much more straight-forward. My goal here is not to become a Ruby wizard but just accomplish this one script.
I have been able to copy faces BUT the faces lose their transformation on copy and just end up at some random size at the origin rather than wherever they were at the model.
Here is the code:
SKETCHUP_CONSOLE.clear
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
temp_wall_primitives = ent.add_group #create a new empty temporary group
mod.definitions.each{|d|
next if d.image? || d.group? || d.name!="WALL"
d.entities.each{ |wall_primative_group|
if wall_primative_group.layer.name == "WALL_PRIMITIVES"
wall_primative_group.entities.each{ |wall_primative_group_entity|
if wall_primative_group_entity.is_a? Sketchup::Face
new_face = temp_wall_primitives.entities.add_face(wall_primative_group_entity.vertices)
end
}
end
}
}
I believe I need to somehow get the transformation of each face and apply it to the new faces as they are created?
Instead of trying to copy the entities from an instance to another one, place a new instance;
# Lets say we have a group.
source_group = model.entities.grep(Sketchup::Group)
# We can "copy" this to another group by fetching it'd definition and adding a new one:
new_group = model.entities.add_group
new_group.entities.add_instance(source_group.definition, source_group.transformation)
In your current solution, where you re-create each face, the reason for the transformation being lost is that vertex positions are relative to their parent. You pass in the vertices you copy from directly: temp_wall_primitives.entities.add_face(wall_primative_group_entity.vertices)
But you need to apply the transformation for the instance they relate to as well.
Additionally your current solution doesn't seem to take into account nested instances. And that faces can have holes in them - in which case face.vertices would not form a valid single loop. Manually recreating faces quickly gets complicated. If you want the whole content of a group or component instance, just make a copy of the instance itself. You can explode the new instance if you want.
But I would question why you have a temporary group in the first place. (Often this turns out to not be necessary. It would help if you explained the higher level task you are trying to perform here.)
Acad::ErrorStatus acedTraceBoundary( const AcGePoint3d& seedPoint, bool detectIslands, AcDbVoidPtrArray& resultingBoundarySet )
Here We can read that resultingBoundarySet : "Contains the resulting boundary in form of AcDbPolyline* objects" but sometimes we got set of AcDbRegions* (when boundary contains spline maybe ). And Regions are what I need. Do You know any way to force acedTraceBoundary always create AcDbRegion not AcDbPolylines ?
There isn't way to force an acedTraceBoundary retrieve set of Plines alone, if in case if it is returning set of regions, you can always extract plines/primitive entities from a region.
Use getSplitCurves on AcDbRegion
Which package is best for a heatmap/image with sorting on rows only, but don't show any dendrogram or other visual clutter (just a 2D colored grid with automatic named labels on both axes). I don't need fancy clustering beyond basic numeric sorting. The data is a 39x10 table of numerics in the range (0,0.21) which I want to visualize.
I searched SO (see this) and the R sites, and tried a few out. Check out R Graphical Manual to see an excellent searchable list of screenshots and corresponding packages.
The range of packages is confusing - which one is the preferred heatmap (like ggplot2 is for most other plotting)? Here is what I found out so far:
base::image - bad, no name labels on axes, no sorting/clustering
base::heatmap - options are far less intelligible than the following:
pheatmap::pheatmap - fantastic but can't seem to turn off the
dendrograms? (any hacks?)
ggplot2 people use geom_tile, as Andrie points out
gplots::heatmap.2 , ref - seems
to be favored by biotech people, but way overkill for my purposes. (no
relation to ggplot* or Prof Wickham)
plotrix::color2D.matplot also exists
base::heatmap is annoying, even with args heatmap(..., Colv=NA, keep.dendro=FALSE) it still plots the unwanted dendrogram on rows.
For now I'm going with pheatmap(..., cluster_cols=FALSE, cluster_rows=FALSE) and manually presorting my table, like this guy: Order of rows in heatmap?
Addendum: to display the value inside each cell, see: display a matrix, including the values, as a heatmap . I didn't need that but it's nice-to-have.
With pheatmap you can use options treeheight_row and treeheight_col and set these to 0.
just another option you have not mentioned...package bipartite as it is as simple as you say
library(bipartite)
mat<-matrix(c(1,2,3,1,2,3,1,2,3),byrow=TRUE,nrow=3)
rownames(mat)<-c("a","b","c")
colnames(mat)<-c("a","b","c")
visweb(mat,type="nested")
I have been looking everywhere but I can't find a site that shows how to do this.
The thing I want is to be able to select an object from an axes when I click it, so that I can change its colours and stuff.
I just can't figure out how to select a child, I can create objects but not select them.
I have this piece of code I use to create a line:
coord = ginput (2)
x = coord(:,1)
y = coord(:,2)
hline = line(x,y)
I'm not sure If i need to create the objects in an array so that I can select edit/delete them.
I believe I would need to use ButtonDownFcn, but probably I'm doing something completely wrong.
Any help would be appreciated, If I'm missing any information please let me know
Thanks
It is not necessary to use ginput and extract the coordinates. This is done automatically by an built-in "listener" in the figure-window. You are correct in assuming that you can use the ButtonDownFcn property on the object (line, lineseries, or other handle graphics object).
Try to create at simple line from (0,0) to (1,1):
hline = line([0,1],[0,1]) %# create line, save handle in hline
Then you can set the ButtonDownFcn to, for instance, a function handle to an anonymous function:
set( ...
hline, ...
'ButtonDownFcn', #(handle,event)(disp(['You clicked on the line!'])) ...
);
Now try to click on the line. It should print the text in the command window.
The function needs to be able to receive atleast two arguments: (1) the handle of the object itself (the line) and (2) an "event structure". I believe the second argument is just empty when you use line-objects. But your function still needs to receive atleast these two arguments (even if you do not use them).
Read more here: http://www.mathworks.com/help/techdoc/ref/line_props.html.
You can also use your own function (a named function in a file):
set( ...
hline, ...
'ButtonDownFcn', #(handle,event)(namedFunction(handle,event)) ...
);
... or you can use a struct-array if you (expectedly) have other arguments beyound those two.