Batch processing clip layer: " 'NoneType' object has no attribute 'pendingFields' " - qgis

I am trying to clip many vector layers to a boundary by following the tutorial at http://www.qgistutorials.com/en/docs/batch_processing.html
ie using Clip in the Processing Toolbox, then 'execute as batch process'. However, I recieve an error message -
Algorithm Clip starting...
'NoneType' object has no attribute 'pendingFields'
but I don't know what that message means or how to fix it. Thanks for any help
EDIT: in the end I clipped the layers one by one through the 'Geoprocessing - Clip' menu. That worked, so now I suppose the issue is with the batch processing command rather than the shapefiles themselves.

I think the problem is that bash didn't get the target layer.
I get the similar error when I run reprojection.
before the input layer was "A layer", the input is a string.
then I redo select from open layers. the quotation mark disappear.
it works for me.

I've had the same problem. I solved it by using layers from file system instead of opened layers.
This is not very convenient but it can help !

Related

Editing layer via Python script startEditing, do we have to "close" editing?

I'm working on a vector layer where I have to merge all n+i [id] attributes into entity(n)[id] where entities(n+i)[id] equals the entity(n)[id], then delete all n+i entities.
All works fine but I call several times startEditing functions before commiting changes, and my question is: does calling commitChanges closes startEditing, or does it let it opened, like if it was a file descriptor or a pointer which we needed to free after the job's done?
The code is:
olayer.startEditing()
olayer.changeAttributeValue(n,id_obj,id_obj_sum,NULL,True)
olayer.commitChanges()
olayer.startEditing()
i= i-1
while i >=1:
olayer.deleteFeature(n+i)
i=i-1
olayer.commitChanges()
As you can see, we call several times olayer.startEditing, even more because all that code is in while body...
So will that spawn hordes of startEditing "pointers" or will it just continuously set the olayer editable status as "open to edition" ?
Actually the code works, but it's painfully slow, is this the reason why ?
By and large, you should not start the edit mode more than once in your layer.
You can commit at the end of all your changes to the layer, so that your modifications stay in an edit buffer in the meantime.
QgsVectorLayer.commitChanges() can let the edit mode open if you pass a False as parameter (the parameter is called stopEditing, see the docs). Like this:
# If the commit is sucessful, let the edit mode open
layer.commitChanges(False)
Also, have a look at the with edit(layer): syntax in the QGIS docs. Using such syntax you avoid starting/committing/closing the edit mode, QGIS does it for you.
with edit(layer):
# All my layer modifications here
# When this line is reached, my layer modifications are already committed.

Why does this code to stash babylonjs meshes cause an error?

I am loading a .obj file containing meshes of numerals. I want to stash each mesh against its name so that I can create instances later.
The code works fine if I remove the line that is actually stashing the mesh in 'originals'. However when I leave it in it appears that an exception is thrown and caught inside Babylon with the message "BJS - [12:17:50]: Unable to load assets from /threedee/InputMonoNumerics.obj: Error in onSuccess callback".
originals = {}
BABYLON.SceneLoader.LoadAssetContainer(assetPath, assetName, scene, (container) ->
container.addAllToScene()
for i in[0...scene.meshes.length]
mesh = scene.meshes[i]
if (mesh.name.startsWith('numeral'))
character = mesh.name.charAt('numeral_'.length)
originals["_#{character}"] = mesh
console.log("This line is never reached.")
mesh
)
This is coffeescript source - but the transpiled code looks exactly as you would expect
Yes - much thanks to caffeinated.tech - obviously (now you come to mention it) try and catch to see the underlying error!
... which was that the debug statements I had put in to help were throwing an error by calling JSON.stringify on Babylon Mesh objects - which are circular - I think because they have a reference to their parent which of course has a reference back to the Mesh.
It is no longer clear what the original problem was - but that's not a problem.

Why is my "waterproof" polyhedron causing "WARNING: Object may not be a valid 2-manifold and may need repair!"?

In the script
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[5,4,1,2],
[5,4,0,3],
[0,1,4],
[2,3,5]]);
cube([1,1,1]);
};
the polyhedron alone works fine (is rendered without warnings), but adding the cube above causes the warning WARNING: Object may not be a valid 2-manifold and may need repair! to be logged and the output to only render some parts of some surfaces.
I'm using OpenSCAD 2015.03-1 on Ubuntu 16.04.
This is because your polyhedron has some faces pointing into the wrong direction, causing issues when calculating the difference().
See the Manual and FAQ for details.
Changing the winding order of the affected polygons fixes the polyhedron:
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[2,1,4,5],
[5,4,0,3],
[0,4,1],
[2,5,3]]);
cube([1,1,1]);
};
The difference is still non-manifold as cutting the cube results in 2 prism shaped objects just touching at one edge. That's also by definition not 2-manifold, so the warning remains.
Depending on how the exported model is supposed to be used, you could choose to ignore this warning and hope the tool processing the 3d model can handle that.
To remove the issue, for example the cube could be made a bit smaller like cube([1, 1, 0.999]).
An unrelated, but still useful strategy for preventing issues later on is to always make the cutting object a bit larger to ensure that no very thin planes remain, e.g. use cube([2,3,1.999], center = true). That will also remove the display artifacts in preview mode.

Sharpdx Direct3D10 How to edit pixels in texture?

I need to change certain pixels in a texture (Texture2D) using Sharpdx with dx10
Right now I got
Texture.Map(0, MapMode.Write, MapFlags.None, out stream);
but I get a "The parameter is incorrect." exception.
All solutions I find are for either dx9 or dx11 or something other then Sharpdx and the used methods don't exist in Sharpdx.Direct3D10, hopefully someone here knows how to do this simple task of editing a texture...

Gate vs toggle clip launch in Max4Live patch

I hope someone is able to help me with this.
Ableton Live when you set a clip's launch mode to gate, it only plays when you hold down the key. I'm using a patch that takes an OSC message to launch the clip, but it will not work as a gate - it needs to have the stop all clips message, and this won't help in my situation.
I need to "call fire" when 1 and "call stop all clips" when 0, but I'm not sure how to do this.
Can anyone help me with which object I should use? I've looked at various gates and swtiches, but I'm missing something.
Thanks.
Create a new object and type "togedge" or "select" (or its shorthand "sel"). Both of them will have 2 outputs: One for 0, one for not 0.
"togedge" will only output if the input changes.
"sel" will always output, and you can enter different numbers to match your input directly (like "sel 34 56").
Btw you can also use "call stop" on the clip_slot object directly instead of "stop_all_clips" on the track object.
After fiddling with the sel object, I discovered this: I needed to change the live.text object used to launch the clip from button to toggle.