Author Topic: change 3Dsolid Extrude distance  (Read 2590 times)

0 Members and 1 Guest are viewing this topic.

WOWENS

  • Newt
  • Posts: 59
change 3Dsolid Extrude distance
« 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.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: change 3Dsolid Extrude distance
« Reply #1 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.

HOSNEYALAA

  • Newt
  • Posts: 103
Re: change 3Dsolid Extrude distance
« Reply #2 on: July 25, 2023, 01:00:15 AM »
Hi
Can you attached example drawing

WOWENS

  • Newt
  • Posts: 59
Re: change 3Dsolid Extrude distance
« Reply #3 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

Bryco

  • Water Moccasin
  • Posts: 1883
Re: change 3Dsolid Extrude distance
« Reply #4 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.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: change 3Dsolid Extrude distance
« Reply #5 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.         }
« Last Edit: August 02, 2023, 04:36:44 AM by gile »
Speaking English as a French Frog

Bryco

  • Water Moccasin
  • Posts: 1883
Re: change 3Dsolid Extrude distance
« Reply #6 on: August 02, 2023, 02:28:30 PM »
Cool for cats as usual gile