Author Topic: Retrieve Slabedges of a AecSlab  (Read 1733 times)

0 Members and 1 Guest are viewing this topic.

mgreven

  • Guest
Retrieve Slabedges of a AecSlab
« on: March 15, 2012, 06:42:44 AM »
Hello,

I want to make a routine in VB .NET wich inserts a block in the middle of a SlabEdge of a AecSlab.
The insert part is no problem, but how can i get the Slabedges (and start / endpoint of them).

Does anyone have an exemple how to get this information in .NET?


kaefer

  • Guest
Re: Retrieve Slabedges of a AecSlab
« Reply #1 on: March 15, 2012, 09:57:17 AM »
how can i get the Slabedges (and start / endpoint of them).

What did you try?

I must admit that this isn't very straightforward and that there are two possible areas of confusion:
1. The property EdgeCount which gives the number of edges is on Face, not on SlabBase as one would usually expect.
2. The edges are retrievable as Curve2d (from SlabLoop) and as Curve3d (via GetEdgeCurveAt method).

Here's a fragment which determines Start- and EndParameter for each edge, calculates the average (let's call it "MiddleParameter") and transforms the resulting Point3d p from ECS to WCS. Be warned that arcs are segmented into quarter circles.

Code - F#: [Select]
  1.             for i in 0 .. slab.Face.EdgeCount - 1 do
  2.                 let edge = slab.GetEdgeCurveAt(i, Autodesk.Aec.Arch.Geometry.FaceType.BaseFace)
  3.                 let sp = edge.GetParameterOf edge.StartPoint
  4.                 let ep = edge.GetParameterOf edge.EndPoint
  5.                 let p = edge.EvaluatePoint (sp + (ep - sp) / 2.)
  6.                 let p' = p.TransformBy slab.Ecs
  7.                ed.WriteMessage("\nId: {0}, Edge middle point: {1} ", i, p')

Edit: Circular slab was converted from MassElement. Need to look into arc segments.
« Last Edit: March 15, 2012, 10:03:57 AM by kaefer »

mgreven

  • Guest
Re: Retrieve Slabedges of a AecSlab
« Reply #2 on: March 15, 2012, 12:01:19 PM »
Thanks for the help. I can make the routine with this info.

Is there a way to find the nearest Slabedge to a Selected Point?
I tried: 

Dim EdgeID As ObjectId = MySlab.Face.FindNearestEdge(New Point2d(pr.Value.X, pr.Value.Y))

But i get the error "Cannot convert Short to ObjectID"


Do i have to loop thru the Edges and calculate the distance to the point?




kaefer

  • Guest
Re: Retrieve Slabedges of a AecSlab
« Reply #3 on: March 15, 2012, 01:01:45 PM »
Dim EdgeID As ObjectId = MySlab.Face.FindNearestEdge(New Point2d(pr.Value.X, pr.Value.Y))

But i get the error "Cannot convert Short to ObjectID"

Please, use the information that can be gleaned from the Object Browser:
Quote
public short FindNearestEdge(Autodesk.AutoCAD.Geometry.Point2d pointOnEdge)
...
Return Values:
The nearest edge id if found; otherwise 0.

Do i have to loop thru the Edges and calculate the distance to the point?

Without digging any deeper it could be that you have to loop through the edges to find the edge id (of type short, see above).

mgreven

  • Guest
Re: Retrieve Slabedges of a AecSlab
« Reply #4 on: March 16, 2012, 08:37:58 AM »
Thanks... I am able to find the slabedge and the position to insert me block.

The only problem is to retrieve the offset direction.
The slab has a positive thickness regardles of the offset direction is to the top or bottom.

I checked the slabstyle, but no luck so far.