TheSwamp

Code Red => .NET => Topic started by: WOWENS on July 06, 2023, 05:19:50 PM

Title: change 3Dsolid Extrude distance
Post by: WOWENS on July 06, 2023, 05:19:50 PM
I have a 3Dsolid and I want to change the Extrude distance with code,
any ideas on how to do this.
Title: Re: change 3Dsolid Extrude distance
Post by: Bryco on July 06, 2023, 07:40:23 PM
I extrude bolts from a 2d circle by clicking 2 pts, but I am not sure there is such a thing as an extrude distance. If the shape you are trying to change is always the same shape you might have a chance to do that.
Title: Re: change 3Dsolid Extrude distance
Post by: HOSNEYALAA on July 25, 2023, 01:00:15 AM
Hi
Can you attached example drawing
Title: Re: change 3Dsolid Extrude distance
Post by: WOWENS on July 26, 2023, 02:46:40 PM
It's a simple beam, I can change the Height with the properties box but I want to access it with .net
Title: Re: change 3Dsolid Extrude distance
Post by: Bryco on August 01, 2023, 02:26:07 PM
In the object browser there is a AcadExtrudedSurfaceClass that has a get,set height  (see Interop.AutoCAD). It may be of some use.
Title: Re: change 3Dsolid Extrude distance
Post by: gile on August 01, 2023, 05:16:42 PM
Hi,
You can use the Solid3d.ExtrudeFaces method.
To find the face to be extruded, you can use the Brep API.
Code - C#: [Select]
  1.         private static void ChangeExtrusionHeight(Solid3d solid, Vector3d extrusionDirection, double newHeight)
  2.         {
  3.             var fullPath = new FullSubentityPath(
  4.                     new[] { solid.ObjectId },
  5.                     new SubentityId(SubentityType.Null, IntPtr.Zero));
  6.             using (var brep = new Brep(fullPath))
  7.             {
  8.                 var face = brep.Faces
  9.                     .Where(f => ((ExternalBoundedSurface)f.Surface).BaseSurface is Plane plane
  10.                                 && plane.Normal.IsParallelTo(extrusionDirection))
  11.                     .Select(f =>
  12.                     {
  13.                         var plane = (Plane)((ExternalBoundedSurface)f.Surface).BaseSurface;
  14.                         return new { f.SubentityPath.SubentId, Height = Math.Abs(plane.Coefficients.D) };
  15.                     })
  16.                     .OrderByDescending(x => x.Height)
  17.                     .First();
  18.                 solid.ExtrudeFaces(new[] { face.SubentId }, newHeight - face.Height, 0.0);
  19.             }
  20.         }
Title: Re: change 3Dsolid Extrude distance
Post by: Bryco on August 02, 2023, 02:28:30 PM
Cool for cats as usual gile