Move Location of Section View

Move Location of Section View

Anonymous
不适用
4,002 次查看
9 条回复
1 条消息(共 10 条)

Move Location of Section View

Anonymous
不适用

I saw a great post n the "The Building Coder" how to create a section view to be aligned with a wall.  I'm working on a project which the wall angle will change and I need to rotate an existing section to match the wall.  

 

Is it possible to set a curve similar to a wall?  I can't seem to find any curve or location point in Lookup.  

 

                LocationCurve locationCurve = wall.WallCurve;

                Transaction t = new Transaction(doc);
                t.Start("Move Wall");
                locationCurve.Curve = LinkedProfile;
                t.Commit();

 

Link to related post. 

http://thebuildingcoder.typepad.com/blog/2012/06/create-section-view-parallel-to-wall.html 

 

Thank you

Danny Bentley. 

0 个赞
已接受的解答 (1)
4,003 次查看
9 条回复
回复 (9)
2 条消息(共 10 条)

jeremytammik
Autodesk
Autodesk

Dear Danny,

 

Thank you for your query and appreciation of The Building Coder.

 

First of all, out of habit, I repeat:

 

For your own comfort and security, all use of transactions should be encapsulated in a `using` statement, cf.

 

http://thebuildingcoder.typepad.com/blog/2012/04/using-using-automagically-disposes-and-rolls-back.h...

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53

 

I think you can indeed change the wall location curve in a manner similar to what you show.

 

However, the code you list above is guaranteed not to work.

 

Look:

 

In this line, you make a copy of the wall location curve:

  

  LocationCurve locationCurve = wall.WallCurve;

  

Then, you change something in the copy:

  

  locationCurve.Curve = LinkedProfile;

  

And then you expect the wall to change?

 

Good luck with that.

 

You might have better luck with

 

  wall.WallCurve = LinkedProfile;

 

Obvious, once pointed out, isn't it?

 

🙂

 

I hope this helps.

 

No guarantee, though, sorry to say.

 

Oh, and you might want to take a look at the ADN Xtra labs sample command Lab2_5_SelectAndMoveWallAndAddColumns in 

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs2.cs#L837-L1102

 

It moves a wall using 

 

  wall.Location.Move( v )

 

by a given vector v.

 

Oh no, re-reading your query, I see you are trying to modify the section view, not the wall location line.

 

No, the section view does not have a location line.

 

It is controlled differently. The Revit SDK sample DynamicModelUpdate shows how to dynamically update a section view to follow a window placed in the model. You can adapt that to follow a wall in a similar fashion.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 个赞
3 条消息(共 10 条)

Anonymous
不适用

Jeremy, 

 

Yes, the question was regarding moving the section view.   I've been looking for the Revit SDK sample without any luck.  Could you point me to the location? 

 

I appreciate you clarifying the using transaction statement.  I will revise my code.  

 

Thank you for your help. 

 

 

0 个赞
4 条消息(共 10 条)

Anonymous
不适用

Jeremy, 

 

Yes, the question was regarding moving the section view.   I've been looking for the Revit SDK sample without any luck.  Could you point me to the location? 

 

I appreciate you clarifying the using transaction statement.  I will revise my code.  

 

Thank you for your help.

0 个赞
5 条消息(共 10 条)

jeremytammik
Autodesk
Autodesk
已接受的解答

Dear Danny,

 

Here is a quick rundown of the pointers step by step:

 

/a/lib/revit/2017.1/SDK/Samples/DynamicModelUpdate/CS/SectionUpdater.cs

 

public void Execute(UpdaterData data)

 

FamilyInstance window = doc.GetElement(m_windowId) as FamilyInstance;
ViewSection section = doc.GetElement(m_sectionId) as ViewSection;

RejustSectionView(doc, window, section);

 

internal void RejustSectionView(Document doc, Element elem, ViewSection section)

 

ElementTransformUtils.RotateElement(doc, m_sectionElement.Id, axis, rotateAngle);

 

ElementTransformUtils.MoveElement(doc, m_sectionElement.Id, translationVec);

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 个赞
6 条消息(共 10 条)

Anonymous
不适用

Perfect!  I forget I have some many awesome examples in the SDK.  I really need to look through them instead of always using google. 

0 个赞
7 条消息(共 10 条)

jeremytammik
Autodesk
Autodesk

Dear Danny,

 

Thank you. Glad it helped.

 

I think you need to use both SDK and Internet searches, and more besides:

 

http://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-ontol...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 个赞
8 条消息(共 10 条)

Anonymous
不适用

Jeremy,

 

I just wanted to add my solution in case anyone else is looking to align section views and create align sections.  

 

Here is a short video on YouTube: 

https://www.youtube.com/watch?v=gkgV2Ff6zC8&index=1&list=PLlyMZ5IcKcciQwUdE9H1m_sjdoTtXvcGY

 

Here is my source code: 

https://github.com/dannysbentley/Sections

 

Cheers 

 

Danny. 

0 个赞
9 条消息(共 10 条)

jeremytammik
Autodesk
Autodesk

Dear Danny,

 

Thank you very much for sharing your complete solution!

 

I am sure that will come in very handy for others as well, so I will gladly edit it into a blog post for readability and easier retrieval, if I may.

 

Some comments on the screen video recording:

 

I would suggest that you reduce your screen resolution beforehand next time you record any videos.

 

I cannot read the command names, or any text at all on the screen, so it is not completely obvious to me what is going on.

 

It probably is to anyone more involved with the issues you demo, of course, so I am sure it is fully adequate for its purpose.

 

On the GitHub repository:

 

A readme is always extremely helpful and important; check out the 'art of readme':

 

http://thebuildingcoder.typepad.com/blog/2016/10/how-to-create-a-new-line-style.html#4

 

Without a license, you are basically prohibiting every sane and honest person from making any use of your code, ever -- a sane and honest person cannot make use of third party software unless it is equipped with a license.

 

Why?

 

Because if it does not have a license now, when I start using it, the original author may come along and add one (possibly very restrictive) later on.

 

A developer can only (safely) use material that has a license already attached to it.

 

 

Furthermore, the `bin` and `obj` directories are not really needed.

 

I generally initalise all my C# .NET GitHub repositories with three settings that are all suggested by GitHub on creating a new repository:

 

  • Readme
  • Visual Studio .gitignore settings
  • MIT license

 

Still, for anyone who knows what he is about and trusts you to not come along with a restrictive license later on, it is perfectly adequate for its purpose, again.

 

Still, if you don't mind, adding the readme, license and removal of bin and obj might clarify and simplify.

 

Thank you!

 

I wish you a wonderful weekend!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 个赞
10 条消息(共 10 条)

jeremytammik
Autodesk
Autodesk

Cool!

 

Thank you very much for adding the readme and license to the GitHub repo!

 

I published a summary of this discussion on the blog for readability and future reference::

 

http://thebuildingcoder.typepad.com/blog/2017/02/moving-the-section-view-location.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 个赞