« Slab Boundary | Main | Slab Side Faces »

November 03, 2008

Comments

Hello,
beautiful site!

We are trying to publish some code from Revit VSTA in our webiste, so I wanted to know how were you able to find the RSS class that shows it with proper colors and indents...

It is available somewhere?
Thank you in advance for your answer,

Stefano

Dear Stefano,

Thank you for the 'beautiful' attribute.

I guess what you mean is how do I format my blog posts so that the source code is displayed nicely and with colour coding? That has nothing to do with RSS at all. I edit my posts manually in HTML. To obtain the colour coding, I make use of the functionality provided by Visual Studio. In addition, I installed a Visual Studio plug-in to copy the selected code snippet as HTML. It adds support to Visual Studio 2005 for copying source code, syntax highlighting, and line numbers as HTML. I insert the clipboard contents into my HTML blog text and that's it, more or less. I also tried to use some other code colouring systems that are independent of Visual Studio. They also work, but they only colour code the C# keywords, not the classes defined in other namespaces, because they do not actually load and analyse the contents of those other namespaces. That is why I ended up using the Visual Studio plug-in after all, in spite of trying to solve the problem myself externally. Simply search on the web for keywords such as "visual studio copy as html". This will probably not work in VSTA, although I am not sure.

Cheers, Jeremy.

Dear Jeremy,

As in DrawPolygons() method of current post, polygons are being drawn using different lines. I am also drawing the polygon like this o nly.
In Revit User Interface, we can draw a polygon like triangle etc. by selecting polygon from model line Draw option.But is there any api method to draw the entire polygon as a single curve instead of set of lines.

Kind Regards,
Shifali


Dear Shifali,

Look at such a triangle through the API. What do you see? Is it not composed of individual model lines?

Cheers, Jeremy.

Dear Jeremy,

Thanks a lot for your reply.
In Revit User Interface, no doubt the triangle/any polygon is composed of model lines only. That means we can not draw a polygon as a single curve?

Actually my issue is I need to consider this polygon which is being drawn by set of lines as a single curve object. Can we do so?

Regards,
Shifali

Dear Shifali,

As said, I see no methods in the Revit API to draw collections of individual model curves to be united into one single object.

You could try creating a group out of them, if that is of any help.

You are of course free to consider the resulting polygon as anything you please :-)

Cheers, Jeremy.

Hi Jeremy,
I'm trying to alter the above code to work with 2011 but I keep getting the following error
"Curve must be in the plane parameter name pCurveCopy" this error has me stumped

Thanks

Anthony

---------------------------------------------------

Private Function NewSketchPlanePassLine(ByVal line As Line) As DB.SketchPlane
Dim aps As Document = globalcdata.Application.ActiveUIDocument.Document
Dim app As Autodesk.Revit.ApplicationServices.Application = aps.Application

Dim p As DB.XYZ = line.EndPoint(0)
Dim q As DB.XYZ = line.EndPoint(1)
Dim norm As DB.XYZ
If p.X = q.X Then
norm = DB.XYZ.BasisX
ElseIf p.Y = q.Y Then
norm = DB.XYZ.BasisY
Else
norm = DB.XYZ.BasisZ
End If
Dim plane As DB.Plane = app.Create.NewPlane(norm, p)
'plane = Autodesk.Revit.Creation.Application.NewPlane(norm, p)

Return aps.Create.NewSketchPlane(plane)
End Function

Private Sub CreateModelLine(ByVal p As DB.XYZ, ByVal q As DB.XYZ)
Dim aps As Document = globalcdata.Application.ActiveUIDocument.Document
Dim app As Autodesk.Revit.ApplicationServices.Application = aps.Application
If p.IsAlmostEqualTo(q) Then

Throw New ArgumentException("Expected two different points.")
End If
Dim line As Line = app.Create.NewLine(p, q, True)
If line Is Nothing Then
Throw New Exception("Geometry line creation failed.")
End If
aps.Create.NewModelCurve(line, NewSketchPlanePassLine(line))

End Sub

Dear Anthony,

Please have a look at this post:

http://thebuildingcoder.typepad.com/blog/2010/05/detail-curve-must-indeed-lie-in-plane.html

You should be able solve your issue using the NewSketchPlaneContainCurve method described in

http://thebuildingcoder.typepad.com/blog/2010/05/model-curve-creator.html

By the way, you seem to be obtaining your two line endpoints p and q from an existing line in the first two lines of code. You then proceed to create a new line using the same points. That seems like a waste of effort to me. Finally, you create a model curve based on the latter. Maybe all of that can be achieved in one fell swoop using the CreateModelCurve method I present in the latter post.

Please let us know whether it works. Thank you!

Cheers, Jeremy.

Hi Jeremy,
Billiant, My app now works perfectly.

I'm generating some model lines from a topo surface, this enables our users to edit the top of retaining walls etc to follow the ground line cut away by building pads.

See link below for finished code.
http://forums.augi.com/showthread.php?p=1089399#post1089399

Thanks Anthony

Dear Anthony,

Thank you very much for the appreciation and sharing your solution. For easy and complete access, I posted it as well, with the source code that you friendlily provided:

http://thebuildingcoder.typepad.com/blog/2010/08/surface-triangulation-tool.html

Cheers, Jeremy.

Dear Jeremy,
Please help me!

How to get area from some points(some Edges)?
or how go create a Face from some points(some Edges)?
I'm a beginner and it's easy with.

Dear Jeremy,
Please help me!

How to get area from some points(some Edges)?
or how to create a Face from some points(some Edges)?
I'm a beginner and it's easy with.

Dear Fizze,

When you say 'get area', do you mean calculate the area? That is a common algorithm which I implemented in the method GetSignedPolygonArea presented in

http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html

You cannot create a Face instance yourself, because it is basically a read-only object returned by the Revit geometry library when you query existing building elements for their geometry.

Cheers, Jeremy.

How to set the hidden parameter in modelCurve

Dear Joseph,

The same way as in any other element: Parameter.Set.

Cheers, Jeremy.

any complete VisualStudio project for creating a 3D model for analysis in Vasari 2.1!?

thank you!

Dear Jeremy,

I'm trying to use this class inside a Revit 2014 Macro, and I'm getting a lot of reference errors and warnings.
Being a complete newbie in this field, I feel lost.
Does this code still apply to 2014 API or should something be changed for it to work?

Dear Samer,

As you can see for yourself above, this code was published in 2008.

It needs adapting to run on Revit 2014.

However, the Creator class introduced and listed above is included in The Building Coder samples, and they are up to date on GitHub:

https://github.com/jeremytammik/the_building_coder_samples

Cheers, Jeremy

Is this works in Revit 2015?

Dear Ananda,

Yes, sure. Just grab the most up-to-date version of The Building Coder samples, get going, and have fun!

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource