static public void UpdateObjectAttrinutes(IAttributeListContainer container, IGeoObject Object2Update) { if (container == null) { return; } for (int i = 0; i < container.ListCount; i++) { container.List(i).Update(Object2Update); if (Object2Update.HasChildren()) { for (int j = 0; j < Object2Update.NumChildren; j++) { container.List(i).Update(Object2Update.Child(j)); } } } }
private void AddPrimitiv(IGeoObject go, Plane pln) { if (go.NumChildren > 0) { for (int i = 0; i < go.NumChildren; i++) { AddPrimitiv(go.Child(i), pln); } } else { if (go is ICurve) { ICurve2D c2d = (go as ICurve).GetProjectedCurve(pln); c2d.UserData.Add("CADability.OriginalGeoObjects", new GeoObjectList(go)); Add(c2d); } } }
private ICurve[] Intersect(IGeoObject go, PlaneSurface pls) { Plane plane = pls.Plane; if (go is Solid) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Solid).GetPlaneIntersection(pls)); } } if (go is Shell) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Shell).GetPlaneIntersection(pls)); } } if (go is Face) { BoundingCube bc = go.GetBoundingCube(); if (bc.Interferes(plane)) { return((go as Face).GetPlaneIntersection(pls)); } } List <ICurve> res = new List <ICurve>(); if (go is Block) { for (int i = 0; i < go.NumChildren; i++) { res.AddRange(Intersect(go.Child(i), pls)); } } return(res.ToArray()); }
private JsonEntity makeJsonEntity(IGeoObject go) { try { JsonEntity res = new JsonEntity { faces = new List <JsonFace>(), lines = new List <JsonLine>(), text = new List <JsonText>(), userData = new Dictionary <string, object>() }; if (go is Solid) { foreach (Face fce in (go as Solid).Shells[0].Faces) { res.faces.Add(makeJsonFace(fce)); } if (ExportEdges) { foreach (Edge edg in (go as Solid).Shells[0].Edges) { if (edg.Curve3D != null) { res.lines.Add(makeJsonLine(edg.Curve3D)); } } } } else if (go is Shell) { foreach (Face fce in (go as Shell).Faces) { res.faces.Add(makeJsonFace(fce)); } if (ExportEdges) { foreach (Edge edg in (go as Shell).Edges) { if (edg.Curve3D != null) { res.lines.Add(makeJsonLine(edg.Curve3D)); } } } } else if (go is Face) { res.faces.Add(makeJsonFace(go as Face)); if (ExportEdges) { foreach (Edge edg in (go as Face).AllEdges) { if (edg.Curve3D != null) { res.lines.Add(makeJsonLine(edg.Curve3D)); } } } } else if (go is Block) { for (int i = 0; i < go.NumChildren; i++) { JsonEntity sub = makeJsonEntity(go.Child(i)); res.faces.AddRange(sub.faces); res.lines.AddRange(sub.lines); res.text.AddRange(sub.text); } } else if (go is ICurve) { ICurve path = (go as ICurve).Approximate(true, precision); if (path is Polyline) { JsonLine pl = new JsonLine(); pl.vertices = new List <JsonPoint>(); for (int i = 0; i < (path as Polyline).Vertices.Length; i++) { pl.vertices.Add(new JsonPoint((path as Polyline).Vertices[i])); } pl.color = getColor(go); res.lines.Add(pl); } if (path is GeoObject.Path) { JsonLine pl = new JsonLine(); pl.vertices = new List <JsonPoint>(); for (int i = 0; i < (path as GeoObject.Path).CurveCount; i++) { pl.vertices.Add(new JsonPoint((path as GeoObject.Path).Curves[i].StartPoint)); } pl.vertices.Add(new JsonPoint((path as GeoObject.Path).Curves.Last().EndPoint)); pl.color = getColor(go); res.lines.Add(pl); } } else if (go is Text) { Text txt = (go as Text); JsonText jst = new JsonText(); jst.location = new JsonPoint(txt.Location); jst.directionx = new JsonPoint(txt.LineDirection); jst.directiony = new JsonPoint(txt.GlyphDirection); jst.font = txt.Font; jst.text = txt.TextString; jst.color = getColor(go); res.text.Add(jst); } if (ExportUserData && go.UserData != null) { res.userData = new Dictionary <string, object>(); foreach (KeyValuePair <string, object> kv in go.UserData) { if (kv.Value.GetType().IsPrimitive || kv.Value is string || kv.Value is Guid) { if (kv.Value == null) { res.userData[kv.Key] = "null"; } else { res.userData[kv.Key] = kv.Value; } } else { TypeAttributes ta = kv.Value.GetType().Attributes; } } // DataContractResolver #if DEBUG if (go.UserData.Count == 0) { res.userData["key1"] = "val1"; res.userData["key2"] = "val2"; } #endif } return(res); } catch (Exception ex) { if (ex is System.Threading.ThreadAbortException) { throw (ex); } throw new ExportToThreeJsException(go); } }