Intersections in different UCS

Intersections in different UCS

stefanveurink68AXD
Advocate Advocate
567 Views
1 Reply
Message 1 of 2

Intersections in different UCS

stefanveurink68AXD
Advocate
Advocate

So, another question for same code i'm working on for dimensioning all intersections of a line. 

 

here's some code: 

 

PromptPointResult ppr = ed.GetPoint("\nSpecify base point: ");
if (ppr.Status != PromptStatus.OK)
   return;
Point3d startpunt = ppr.Value;
//startpunt.TransformBy(ed.CurrentUserCoordinateSystem);

PromptPointOptions opt = new PromptPointOptions("\nSpecify second point: ");
opt.UseBasePoint = true;
opt.BasePoint = startpunt;
ppr = ed.GetPoint(opt);
if (ppr.Status != PromptStatus.OK)
                return;
Point3d eindpunt = ppr.Value;
//eindpunt.TransformBy(ed.CurrentUserCoordinateSystem);

Extents3d ext = maatlijn.GeometricExtents;
double extminx = ext.MinPoint.X;
double extminy = ext.MinPoint.Y;
double extmaxx = ext.MaxPoint.X;
double extmaxy = ext.MaxPoint.Y;
Point3d extmin = new Point3d(extminx, extminy, 0);
Point3d extmax = new Point3d(extmaxx, extmaxy, 0);

Point3dCollection punten = new Point3dCollection();

//selectionfilter
TypedValue[] filterlijst = new TypedValue[1];
filterlijst[0] = new TypedValue(0, "LINE,POLYLINE,CIRCLE,ARC");
SelectionFilter filter = new SelectionFilter(filterlijst);
//selectionfilter

SelectionSet set = ed.SelectCrossingWindow(extmin, extmax, filter).Value;

foreach (ObjectId id in set.GetObjectIds())
{
Entity ent = tra.GetObject(id, OpenMode.ForRead) as Entity;
maatlijn.IntersectWith(ent, Intersect.OnBothOperands, punten, IntPtr.Zero, IntPtr.Zero);
}
//foreach (Point3d punt in punten)
//{
//punt.TransformBy((ed.CurrentUserCoordinateSystem));
//}

 

Some time later, I sort the points by X-coordinate. 

 

//sorteren 
Point3dCollection punten2 = new Point3dCollection(
punten
.Cast<Point3d>()
.OrderBy(point => point.X)
.ToArray());
//sorteren

 

It works perfectly fine when UCS is WCS. But when UCS is different, it gives an error here, concerning 'out of range'. 

 

Anyone sees the problem? Should I somehow transform the selectionset? or extents? If yes, then how? Since I see nothing like the 'transformby' here?

 

0 Likes
Accepted solutions (1)
568 Views
1 Reply
Reply (1)
Message 2 of 2

stefanveurink68AXD
Advocate
Advocate
Accepted solution

Got the problem solved allready, by a workaround offered by this topic

 

https://forums.autodesk.com/t5/net/get-current-ucs-using-vb-net/td-p/7611670 

' save current ucs
Dim ucs As Matrix3d = ed.CurrentUserCoordinateSystem

' set the CS to World
ed.CurrentUserCoordinateSystem = Matrix3d.Identity

' do yor stuff...

' restore the previous ucs
ed.CurrentUserCoordinateSystem =ucs
0 Likes