How to change Element.Geometry?

How to change Element.Geometry?

Anonymous
Not applicable
2,810 Views
7 Replies
Message 1 of 8

How to change Element.Geometry?

Anonymous
Not applicable

Hi

Is it possible to change Element.Geometry? I get points from Element.Geometry,and I want to change the values of these points.But it seems impossible by Revit API.

0 Likes
Accepted solutions (2)
2,811 Views
7 Replies
Replies (7)
Message 2 of 8

BardiaJahan
Advocate
Advocate
Accepted solution

Element.Geometry is a {get;} property which basically means you can only retrieve it and you cannot assign new value/data to it. To change the geometry of element you need to modify the element by available tools/options in its class for example to edit a wall you can change its location curve, etc.

0 Likes
Message 3 of 8

Anonymous
Not applicable

Thank you for your answer.

When I change Elements' location curves ,it takes even an hour to make changes in some revit examples.Is there any way to improve efficiency?

Here is my code and file screenshots.

0 Likes
Message 4 of 8

BardiaJahan
Advocate
Advocate

I am not an expert but there are a few things that might help:

1 - Try to avoid LINQ and use revit filters instead (however it is a one time thing in your code and shouldn't really matter.

2 - I would say use foreach to implement the loop and avoid using ElementAt (I think it is not very efficient)

3 - Another thing that I think would improve the efficiency is to do all the analysis in a separate thread than your RevitAPI-calling thread. So your plugin would calculate and analyze oldPoint and tempPoint in one thread and does the transaction and creates lines in the main thread.

4 - I would like to know your findings if you tried any of these or even a different approach.

Message 5 of 8

matthew_taylor
Advisor
Advisor

Hello,

There's one thing that looks particularly taxing in your code, and another one that may be contributing.

1. Do one transaction around your loop, not a loop with transactions in it.

2. The get geometry part. Is that necessary? If it is, I'd run it in the loop (as opposed to your

FilteredElementCollector). If it's a wall, it's going to have geometry.

 

Cheers,

 

-Matt

 

p.s. If you just want walls, you could filter just for them using. (in vb.net) .ofclass(gettype (db.wall))


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 6 of 8

Anonymous
Not applicable

Thank you for your answer.

I added this line of code. Change IEnumerable to List.

List<Element> elems = elems1.ToList();

Efficiency has been greatly improved.I am confused about this, but it does happen.

0 Likes
Message 7 of 8

Anonymous
Not applicable

Thank you for your answer.

I want to embed a watermark in Revit.Watermarks are embedded by coordinate values.

But when I read his article, it was found impossible.As shown in the following screenshot.

QQ截图20161215133424.png

I have three questions

1.For example, I get a triangular net, read the point information, modify it, then update back. Is this possible?

2.Only by changing the file format,Can I change the geometric coordinates ?

3.When I change the eighth decimal place of the value of locationpoint, revit will report an error, which is very distressing.How do I avoid this situation?

0 Likes
Message 8 of 8

matthew_taylor
Advisor
Advisor
Accepted solution

Hello,

Referencing an ienumerable value will cause issues if referenced multiple times.

A quick google will bring up discussions like this:

http://stackoverflow.com/questions/8240844/handling-warning-for-possible-multiple-enumeration-of-ien...

 

Putting the transactions around your entire modification loop will make a massive improvement also.

 

As for your final message, it appears to be unrelated to this conversation, and isn't clear. I would suggest creating a new post, and being very clear about what your questions are.

8 decimal places? Forget about it!

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes