Remove/Delete/Undo Parts - revit-api

I have splitted the wall into parts. Now I want to remove the parts and keep the original wall. How do I remove/delete/undo the parts that have already been created? I have the partids which I would like to remove.
.ActiveDoc.Delete(partid) doesn't work out and throws an error.

You can accomplish this by deleting the PartMaker associated with the source element:
revitDoc.Delete(PartUtils.GetAssociatedPartMaker(revitDoc, SourceElementId).Id);
Have fun!

Related

Creating text summary using NLP

I am in middle of applying NLP to the set of comments that I have received from my data. These comments are stored in one column. I have cleaned them altogether stored them in a list. There are no stop words, special characters etc. Now I want to create a summary from this text. What could be the best method to do that? I have already failed myself with heapq, so I dont want any solution around that.
My clean text is stored in list named : clean_text_summary and it looks like this :
clean_text_summary = ['You are so bad - I hate your product','I am going to deregister','You are frauds'....]
I need to get most common things that people have talked about as a summary.

Pyqt Custom QPolygon getting deleted: RuntimeError: wrapped C/C++ object of type ImagePolygon has been deleted

I have a program which loads multiple images and each image has an array of polygons which are represented by a custom QGraphicsPolygon item. I load 1 image at a time with its respective polygons into two QGraphicsScene (new QGraphicsScene on each load). The problem I am encountering is that after switching between image a couple times I get the following error:
"RuntimeError: wrapped C/C++ object of type ImagePolygon has been deleted". This implementation used to work well, but I have added a lot of stuff to the program since and now I get the error.
I know that I am never loosing my references to the custom QGraphicsPolygons and the only thing that is getting deleted inside them is the polygon itself. All other membervariables stay intact. Unfortunately I have not been able to pinpoint the exact region of the code where the polygon inside the QGraphicsPolygon gets deleted and the code is too long to post here.
I have also tried to simple set a new QPolygon to the QGraphicsPolygon item each time I add it to the scene, but this gives me the same error.
Please let me know if anybody knows what could be deleting this item. Keep in my I am never loosing reference to the QGraphicsPolygonItem.
I would also appreciate if somebody knew of a good way to debug this. I am sure I could fix the error if I could find it.
Thank you in advance
After a lot of testing I think I found the problem. Since in my implementation I delete the QGraphicsScene everytime I show a new image, I believe this was deleting the polygons as well. I don't know why this was not happening before, but I managed to fix it by first removing all items from the scene. I had to iterate through the items, because using the clear() method in the scene deletes them.

How to ungroup elements in Snap SVG

I am using Snap SVG to build an editor.
I have a group tag with some transform.
I want to ungroup the group. I tried adding the elements in the group to parent with a for loop, but the transforms are not working as expected in the ungrouped elements.
Can anybody tell me a way to ungroup elements?
Please find the JS Bin here.
https://jsbin.com/jinita/edit?js,output
Here when I drag the black rectangle, the entire group also moves.
When I drop it, I try to ungroup it, but the transforms are not applying for the group.
PS: I can't call drag() on the group element
The code is a bit confusing, as it looks like you are trying to add a group to itself, but I may be misunderstanding it. I have amended it slightly and selected the group by ID, just to know its the correct one, rather than css selectors.
jsfiddle
The key part I amended for the transforms is this line...
item.transform( g.transform().localMatrix.toTransformString() )
Edit: In this case, you can probably shorten it further to
item.transform( g.transform() )
This makes sure that we are getting the group transform at time of removing from the group, and convert it using toTransformString() (I'm not sure thats entirely necessarily, but often seems to eliminate oddities).
Edit: After the question has been amended slightly, it may be that you actually want the full matrix applying in which case it would be ...
item.transform( item.transform().globalMatrix.toTransformString() )
jsbin

Persist highlight in CListCtrl after double click

Figured it out. LVIF_STATE should have been LVIF_IMAGE. See, I knew it was elementary...
I have a CListView derived class with an OnDoubleClick() handler in a VC++6.0 project. I need to persist the highlighting of the selected item after the OnDoubleClick() handler has done its thing. I had thought that
GetListCtrl().SetItemState(m_nHighlightIndex,LVIS_SELECTED, LVIF_STATE);
would do the trick (assuming that m_nHighlightIndex holds the index of the selected item), but no combination of that and various attempts to invalidate the client area has worked, in either OnDoubleClick() or OnUpdate(). This seems like such an elementary thing to do, but thus far it baffles me. Any help would be greatly appreciated.
Just so it looks answered (and apologies if this is bad form):
LVIF_STATE should have been LVIF_IMAGE. See, I knew it was elementary...

SPListItem in FormsLib does not handle blank values

I have a FormsLib with a couple of xml files in there. When I pull up either InfoPath or the standard EditForm and clear out a value on the SPListItem (sync with the xml file) the old value comes back. If I add a space it works. I have tried it via the OM also and the result is the same.
So, for example, if I have a field with the value "Johan" and I pull up the form and clear out that value it still says "Johan" after the update.
Anyone else had any experience with this?
Yes. I have encountered this and the work around I came up with was to add a single space instead of clearing out the field entirely. In my experience though, it only happened if I made the changes in the EditForm. When done in InfoPath, it seemed to work.
Of course, after using " " as my empty value, I had to trim it whenever I needed to check if the field was indeed blank.
I have found an alterntive solution to this issue and I have blogged about it:
http://johanleino.wordpress.com/2009/08/24/node-demotion-does-not-work-with-blank-empty-values/

Resources