<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Block are not visible after clipping in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/block-are-not-visible-after-clipping/m-p/12650616#M4957</link>
    <description>&lt;P&gt;I have a nested block. When I apply clipping on that block by c# Api after that some of block hidden. They are not visible, but they are there in same clipped block. code for reference.&lt;/P&gt;&lt;P&gt;const string filterDictName = "ACAD_FILTER";&lt;BR /&gt;const string spatialName = "SPATIAL";&lt;/P&gt;&lt;P&gt;[CommandMethod("TEST")]&lt;BR /&gt;public void Test()&lt;BR /&gt;{&lt;BR /&gt;var doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;var db = doc.Database;&lt;BR /&gt;var ed = doc.Editor;&lt;/P&gt;&lt;P&gt;// Select a block to clip&lt;/P&gt;&lt;P&gt;var peo = new PromptEntityOptions("\nSelect a block reference to clip:");&lt;BR /&gt;peo.AllowNone = false;&lt;BR /&gt;peo.SetRejectMessage("\nNot a block reference.");&lt;BR /&gt;peo.AddAllowedClass(typeof(BlockReference), false);&lt;BR /&gt;var per = ed.GetEntity(peo);&lt;BR /&gt;if (per.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;/P&gt;&lt;P&gt;// Select rectangle to clip&lt;/P&gt;&lt;P&gt;var ppo = new PromptPointOptions("\nSelect first clip corner: ");&lt;BR /&gt;ppo.AllowNone = false;&lt;BR /&gt;var ppr = ed.GetPoint(ppo);&lt;BR /&gt;if (ppr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;var pt1 = ppr.Value;&lt;/P&gt;&lt;P&gt;var pco = new PromptCornerOptions("\nSelect second clip corner: ", pt1);&lt;BR /&gt;ppr = ed.GetCorner(pco);&lt;BR /&gt;if (ppr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;var pt2 = ppr.Value;&lt;/P&gt;&lt;P&gt;using (var tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;// Transform and re-order points&lt;/P&gt;&lt;P&gt;BlockReference br = (BlockReference)tr.GetObject(per.ObjectId, OpenMode.ForRead);&lt;BR /&gt;double scale = br.ScaleFactors[0];&lt;BR /&gt;var xform =&lt;BR /&gt;Matrix2d.Rotation(-br.Rotation, Point2d.Origin) *&lt;BR /&gt;Matrix2d.Displacement(new Vector2d(-br.Position.X, -br.Position.Y)) ;&lt;/P&gt;&lt;P&gt;Matrix2d matrix2d = Matrix2d.Scaling(1/scale, Point2d.Origin);&lt;BR /&gt;Point2dCollection pts =&lt;BR /&gt;new Point2dCollection(2) {&lt;BR /&gt;new Point2d(pt1.X, pt1.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt2.X, pt1.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt2.X, pt2.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt1.X, pt2.Y).TransformBy(xform).TransformBy(matrix2d)};&lt;/P&gt;&lt;P&gt;// Create spatial filter&lt;BR /&gt;// Just zeroes for the elevation and clip depths&lt;/P&gt;&lt;P&gt;var sfd = new SpatialFilterDefinition(pts, Vector3d.ZAxis, 0.0, 0.0, 0.0, true);&lt;BR /&gt;var sf = new SpatialFilter();&lt;BR /&gt;sf.Definition = sfd;&lt;/P&gt;&lt;P&gt;// Create extension dictionary if doesn't exist&lt;/P&gt;&lt;P&gt;if (br.ExtensionDictionary == ObjectId.Null)&lt;BR /&gt;{&lt;BR /&gt;br.UpgradeOpen();&lt;BR /&gt;br.CreateExtensionDictionary();&lt;BR /&gt;br.DowngradeOpen();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Add spatial filter to extension dictionary&lt;/P&gt;&lt;P&gt;var xDict = (DBDictionary)tr.GetObject(br.ExtensionDictionary, OpenMode.ForWrite);&lt;BR /&gt;if (xDict.Contains(filterDictName))&lt;BR /&gt;{&lt;BR /&gt;var fDict = (DBDictionary)tr.GetObject(xDict.GetAt(filterDictName), OpenMode.ForWrite);&lt;BR /&gt;if (fDict.Contains(spatialName))&lt;BR /&gt;fDict.Remove(spatialName);&lt;BR /&gt;fDict.SetAt(spatialName, sf);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;var fDict = new DBDictionary();&lt;BR /&gt;xDict.SetAt(filterDictName, fDict);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(fDict, true);&lt;BR /&gt;fDict.SetAt(spatialName, sf);&lt;BR /&gt;}&lt;BR /&gt;tr.AddNewlyCreatedDBObject(sf, true);&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;ed.Regen();&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2024 12:30:06 GMT</pubDate>
    <dc:creator>manasi_patilESZTV</dc:creator>
    <dc:date>2024-03-19T12:30:06Z</dc:date>
    <item>
      <title>Block are not visible after clipping</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-are-not-visible-after-clipping/m-p/12650616#M4957</link>
      <description>&lt;P&gt;I have a nested block. When I apply clipping on that block by c# Api after that some of block hidden. They are not visible, but they are there in same clipped block. code for reference.&lt;/P&gt;&lt;P&gt;const string filterDictName = "ACAD_FILTER";&lt;BR /&gt;const string spatialName = "SPATIAL";&lt;/P&gt;&lt;P&gt;[CommandMethod("TEST")]&lt;BR /&gt;public void Test()&lt;BR /&gt;{&lt;BR /&gt;var doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;var db = doc.Database;&lt;BR /&gt;var ed = doc.Editor;&lt;/P&gt;&lt;P&gt;// Select a block to clip&lt;/P&gt;&lt;P&gt;var peo = new PromptEntityOptions("\nSelect a block reference to clip:");&lt;BR /&gt;peo.AllowNone = false;&lt;BR /&gt;peo.SetRejectMessage("\nNot a block reference.");&lt;BR /&gt;peo.AddAllowedClass(typeof(BlockReference), false);&lt;BR /&gt;var per = ed.GetEntity(peo);&lt;BR /&gt;if (per.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;/P&gt;&lt;P&gt;// Select rectangle to clip&lt;/P&gt;&lt;P&gt;var ppo = new PromptPointOptions("\nSelect first clip corner: ");&lt;BR /&gt;ppo.AllowNone = false;&lt;BR /&gt;var ppr = ed.GetPoint(ppo);&lt;BR /&gt;if (ppr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;var pt1 = ppr.Value;&lt;/P&gt;&lt;P&gt;var pco = new PromptCornerOptions("\nSelect second clip corner: ", pt1);&lt;BR /&gt;ppr = ed.GetCorner(pco);&lt;BR /&gt;if (ppr.Status != PromptStatus.OK)&lt;BR /&gt;return;&lt;BR /&gt;var pt2 = ppr.Value;&lt;/P&gt;&lt;P&gt;using (var tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;// Transform and re-order points&lt;/P&gt;&lt;P&gt;BlockReference br = (BlockReference)tr.GetObject(per.ObjectId, OpenMode.ForRead);&lt;BR /&gt;double scale = br.ScaleFactors[0];&lt;BR /&gt;var xform =&lt;BR /&gt;Matrix2d.Rotation(-br.Rotation, Point2d.Origin) *&lt;BR /&gt;Matrix2d.Displacement(new Vector2d(-br.Position.X, -br.Position.Y)) ;&lt;/P&gt;&lt;P&gt;Matrix2d matrix2d = Matrix2d.Scaling(1/scale, Point2d.Origin);&lt;BR /&gt;Point2dCollection pts =&lt;BR /&gt;new Point2dCollection(2) {&lt;BR /&gt;new Point2d(pt1.X, pt1.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt2.X, pt1.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt2.X, pt2.Y).TransformBy(xform).TransformBy(matrix2d),&lt;BR /&gt;new Point2d(pt1.X, pt2.Y).TransformBy(xform).TransformBy(matrix2d)};&lt;/P&gt;&lt;P&gt;// Create spatial filter&lt;BR /&gt;// Just zeroes for the elevation and clip depths&lt;/P&gt;&lt;P&gt;var sfd = new SpatialFilterDefinition(pts, Vector3d.ZAxis, 0.0, 0.0, 0.0, true);&lt;BR /&gt;var sf = new SpatialFilter();&lt;BR /&gt;sf.Definition = sfd;&lt;/P&gt;&lt;P&gt;// Create extension dictionary if doesn't exist&lt;/P&gt;&lt;P&gt;if (br.ExtensionDictionary == ObjectId.Null)&lt;BR /&gt;{&lt;BR /&gt;br.UpgradeOpen();&lt;BR /&gt;br.CreateExtensionDictionary();&lt;BR /&gt;br.DowngradeOpen();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Add spatial filter to extension dictionary&lt;/P&gt;&lt;P&gt;var xDict = (DBDictionary)tr.GetObject(br.ExtensionDictionary, OpenMode.ForWrite);&lt;BR /&gt;if (xDict.Contains(filterDictName))&lt;BR /&gt;{&lt;BR /&gt;var fDict = (DBDictionary)tr.GetObject(xDict.GetAt(filterDictName), OpenMode.ForWrite);&lt;BR /&gt;if (fDict.Contains(spatialName))&lt;BR /&gt;fDict.Remove(spatialName);&lt;BR /&gt;fDict.SetAt(spatialName, sf);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;var fDict = new DBDictionary();&lt;BR /&gt;xDict.SetAt(filterDictName, fDict);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(fDict, true);&lt;BR /&gt;fDict.SetAt(spatialName, sf);&lt;BR /&gt;}&lt;BR /&gt;tr.AddNewlyCreatedDBObject(sf, true);&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;ed.Regen();&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 12:30:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-are-not-visible-after-clipping/m-p/12650616#M4957</guid>
      <dc:creator>manasi_patilESZTV</dc:creator>
      <dc:date>2024-03-19T12:30:06Z</dc:date>
    </item>
  </channel>
</rss>

