3D_PolyOffset

Short description

  • Creates a 3D offset of a selected 3D polyline.
  • Converts the original 3D polyline into a temporary 2D polyline.
  • Applies a user-defined offset distance.
  • Reconstructs a new 3D polyline using original Z-coordinates.
  • Restores system variables and cleans up temporary entities.

Command:

  • Command name: OFFSET3D
  • Select a 3D polyline when prompted.
  • Enter the offset distance via keyboard input.

Description:

  • Saves current system variables (OSMODE, PLINETYPE, VIEWDIR).
  • Switches to World UCS and disables object snaps.
  • Extracts all vertex coordinates from the selected 3D polyline.
  • Generates a temporary 2D polyline using XY coordinates only (Z set to 0).
  • Offsets the temporary 2D polyline by a specified distance.
  • Reads offset vertex coordinates.
  • Creates a new 3D polyline by combining offset XY values with original Z values.
  • Deletes temporary 2D polylines.
  • Restores original system settings.

Helper function: (if any)​

  • Function name: polypt
  • Validates whether the selected entity is a POLYLINE.
  • Iterates through all vertices until SEQEND is reached.
  • Extracts X, Y, and Z coordinates (group code 10).
  • Stores vertex coordinates in the global list ppt_list.
  • Displays an error message if the entity is not a polyline.

Functionalities:

  • 3D polyline vertex extraction.
  • Temporary 2D polyline generation.
  • Keyboard-driven offset distance input.
  • Automated 2D offset operation.
  • Reconstruction of a 3D polyline with preserved elevation values.
  • Automatic cleanup of intermediate geometry.
  • System variable state preservation and restoration.

Result:

  • 3D polyline vertex extraction.
  • Temporary 2D polyline generation.
  • Keyboard-driven offset distance input.
  • Automated 2D offset operation.
  • Reconstruction of a 3D polyline with preserved elevation values.
  • Automatic cleanup of intermediate geometry.
  • System variable state preservation and restoration.

Images, animations etc.

Pixel

XAML code:

<ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
 
 <src:RibbonToolTip x:Key="3D_PolyOffset">
 <src:RibbonToolTip.ExpandedContent>
 <StackPanel>
 <TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: OFFSET3D</Bold>
<LineBreak/>
<Hyperlink>https://www.cadtutor.net/forum/topic/221-how-do-i-offset-3d-polyline/page/2/</Hyperlink>
<LineBreak/>
<Hyperlink>http://www.black-cad.de/starten.htm</Hyperlink>
<LineBreak/>
<Hyperlink>https://www.ant-ares.de/</Hyperlink>
<LineBreak/>		
Description: This function will ask the user to select a 3d-polyline. This 3d-polyline will be projected on the plane z=0. There will be done the offset- command in 2d and then the offsetted 3d-polyline will be constructed from the 2d- and 3d coordinates. 
<LineBreak/>	
<Bold>Description</Bold><LineBreak/>
This AutoLISP program performs a 3D Offset operation on an existing <Span Foreground="DarkRed">3D Polyline</Span>.
It temporarily projects the 3D Polyline into a 2D plane, applies an offset distance entered by the user, and then rebuilds a new offset 3D Polyline that follows the original’s elevation pattern. <LineBreak/>

<Bold>Main command</Bold><LineBreak/>
<Span Foreground="DarkRed">OFFSET3D</Span> — creates a 3D offset of a selected 3D Polyline. <LineBreak/>

<Bold>Sub-function</Bold><LineBreak/>
<Span Foreground="DarkRed">polypt</Span> — extracts the list of vertex points (XYZ coordinates) from a Polyline entity. <LineBreak/>

<Bold>What the user does</Bold><LineBreak/>
• Run <Span Foreground="DarkRed">OFFSET3D</Span>.<LineBreak/>
• Select a 3D Polyline when prompted. <LineBreak/>
• Enter the desired offset distance using the keyboard. <LineBreak/>
• Wait while the program creates a new 3D offset version of the polyline. <LineBreak/>

<Bold>Main steps performed</Bold><LineBreak/>
• Saves current AutoCAD system variables:
<Span Foreground="DarkRed">OSMODE</Span>, <Span Foreground="DarkRed">PLINETYPE</Span>, and <Span Foreground="DarkRed">VIEWDIR</Span>. <LineBreak/>
• Disables object snaps and sets PLINETYPE to 0 to work in classic polyline mode. <LineBreak/>
• Sets the UCS to the World Coordinate System and switches the view to a top (plan) view for accurate projection. <LineBreak/>
• Uses the helper function <Span Foreground="DarkRed">(polypt)</Span> to extract all vertex coordinates from the selected polyline. <LineBreak/>
• Creates a temporary 2D polyline using the (x, y) coordinates from the original 3D polyline. <LineBreak/>
• Prompts the user for the offset distance: <Span Foreground="DarkRed">(getreal "\ndistance by keyboard: ")</Span>. <LineBreak/>
• Executes the standard AutoCAD <Span Foreground="DarkRed">OFFSET</Span> command to offset the temporary 2D polyline. <LineBreak/>
• Extracts vertex points from the new offset 2D polyline using <Span Foreground="DarkRed">(polypt)</Span> again. <LineBreak/>
• Builds a new <Span Foreground="DarkRed">3D Polyline</Span> by combining the original Z-values with the offset XY-coordinates. <LineBreak/>
• Erases temporary 2D geometry used during the process. <LineBreak/>
• Restores previous AutoCAD settings for OSMODE, PLINETYPE, and view direction. <LineBreak/>

<Bold>Result</Bold><LineBreak/>
A new <Span Foreground="DarkRed">3D Polyline</Span> is created, offset from the original by the specified distance, while retaining the vertical (Z) profile of the source polyline. <LineBreak/>

<Bold>Key functionalities</Bold><LineBreak/>
• Generates a 3D offset copy of an existing 3D Polyline. <LineBreak/>
• Maintains elevation values of the original geometry. <LineBreak/>
• Automatically handles conversion between 3D and 2D projections. <LineBreak/>
• Uses the <Span Foreground="DarkRed">polypt</Span> function to extract and rebuild vertex lists. <LineBreak/>
• Restores system settings to ensure safe and reversible execution. <LineBreak/>
• Accepts custom offset distances entered manually. <LineBreak/>
• Removes intermediate temporary polylines automatically. <LineBreak/>

<Bold>Helper function details</Bold><LineBreak/>
<Span Foreground="DarkRed">polypt(ss)</Span> — Checks if the selected entity is a <Span Foreground="DarkRed">POLYLINE</Span> and builds a list of all its vertex coordinates.
If the selected object is not a polyline, it displays:
<Span Foreground="Red">"this is not a POLYLINE !"</Span> and exits the routine. <LineBreak/>

<Bold>Important implementation notes</Bold><LineBreak/>
• The routine works only with 3D Polylines (<Span Foreground="DarkRed">POLYLINE</Span> entities of 3D type). <LineBreak/>
• The offset distance must be input manually; no dynamic preview is provided. <LineBreak/>
• The elevation data for the new polyline is inherited from the original 3D geometry. <LineBreak/>
• The function temporarily redefines the view to ensure correct offset direction. <LineBreak/>
• All temporary objects created during the operation are automatically erased at the end. <LineBreak/>
• Recommended to save your drawing before running, as complex 3D offsets can create geometry variations. <LineBreak/>

</TextBlock>
 
 <!-- Use MediaElement for GIF (static first frame) and Image as fallback -->

 
 </StackPanel>
 </src:RibbonToolTip.ExpandedContent>
 </src:RibbonToolTip>
</ResourceDictionary>

Additional info:

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x