Jump to content
free2fly

How do I offset 3d Polyline

Recommended Posts

seth007

Ok, I gave it a try.

 

I'm having a problem:

 

On running this code it gives me the error it cand find the library:

'set to uppercase

FilterStr = StrConv(ObjType, vbUpperCase)

ObjectStr = StrConv(objEnt.ObjectName, vbUpperCase)

ObjectStr2 = ObjectStr

ObjectStr = Mid(ObjectStr, InStr(1, ObjectStr, "DB", 1) + 2)

I'm not used to vba, (I like vbnet or C#) :)

 

Do I need a reference here, an import or using, that points to that library?

Share this post


Link to post
Share on other sites
scj

Some times ago I made my version of Offset3d.lsp

Regards

Jochen

offset3d.lsp

Share this post


Link to post
Share on other sites
seth007
Some times ago I made my version of Offset3d.lsp

Regards

Jochen

 

this works like a charm, thanks

Share this post


Link to post
Share on other sites
CarlosBZ

Very useful. Thank you very much for sharing.

Share this post


Link to post
Share on other sites
Tyke

For people with AutoCAD Civil 3D there is a native 3D offset command _AeccOffsetFeature which is the 3D offset command.

Share this post


Link to post
Share on other sites
John1951

To make this work I made a form with a command button and 2 text boxes, textboxZ and textboxV. I added this code to the command_click event of the command button:

 

 

Private Sub CommandButton1_Click()

Dim picked3dPoly As Acad3DPolyline

Dim old3dPoly As Acad3DPolyline

' Begin the selection

Dim returnObj As AcadObject

Dim basePnt As Variant

 

On Error Resume Next

 

' The following example waits for a selection from the user

RETRY:

ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select a 3D Polyline object"

 

If Err 0 Then

Err.Clear

MsgBox "Program ended.", , "GetEntity Example"

Exit Sub

Else

returnObj.Update

If (returnObj.EntityName = "AcDb3dPolyline") Then

 

Set picked3dPoly = returnObj

z# = Val(TextBoxZ.Text)

h# = Val(TextBoxH.Text)

Call Offset3dPoly(picked3dPoly, h#, z#, "0", old3dPoly)

returnObj.Update

Else

GoTo RETRY

End If

End If

 

GoTo RETRY

 

End Sub

Share this post


Link to post
Share on other sites
John1951

Forgot to add that the Offset3dPoly subroutine code must be added to the General section of the form code

Share this post


Link to post
Share on other sites
John1951

Sorry textboxH not textboxV

Share this post


Link to post
Share on other sites
Lippens Infra
On 6/5/2010 at 2:47 PM, scj said:

Some times ago I made my version of Offset3d.lsp

Regards

Jochen

offset3d.lsp 4.48 kB · 325 downloads

This works, but the Z-values of the points are not the same at every point.  

I have the example in  attachment.

Anyone  has an update/hotfix/...

Thanks a lot

offset3d.dwg

Share this post


Link to post
Share on other sites
ammobake

There may also be an app in the autodesk app store that may be able to perform this function.

But as someone mentioned before, save for using lisp routines or add-ons, this kind of offset in vanilla Autocad won't work.

 

I guess my question is why are you offsetting - are you intending to turn a 3d polyline into a cylindrical object (like offsetting from the center of the 3dpolyline) or are you offsetting in one direction from the source in 3d space?

 

Offsetting as a polyline and then converting that polyline to a 3d polyine is a sound alternative just depending on what outcome you are looking for and what drawing/geometry you are dealing with. One could then rotate the object and/or tweak the nodes of the 3d polyline to adjust their positions, manually.

 

In most cases when u are dealing with 3d solids or meshes it is imperitive to think of your precursors in a coplanar context, first, since those objects are needed to either extrude to a 3d solid or to apply a rulesurf, edgesurf, or loft command (though loft will work on open plines and splines).  You can always rotate those objects in 3d space before extruding or adding meshes but the source geometry would still be coplanar.

 

So working in 3D is always a matter of working out in your brain what you'll need to do for step1, step2, step3, etc... and planning out those actions beforehand to achieve a desired outcome.

 

There is a tool on the autodesk app store that can offset splines - but it is unclear if it works on splines with 3d geometry and my gut sais that's likely a "no".  (A quadratic spline is basically just a parabola because it is always coplanar but cubic splines can twist in 3d space because they are not).

 

Offset command in autocad only works on planar lines, splines and polylines though.

 

It is possible to use LISP commands to emulate what a 3d polyline offset might look like - by analyzing the geometry of the source object and performing more of copy/paste type function where the offset is in a specific direction in 3d space from the source point at a specified distance (though there are other tricks one could program).

 

-ChriS

Share this post


Link to post
Share on other sites
Joe Kycek

I recently received an email about this post 11 years later; in 2020.    'seth007' had posted that the code crashed;

which I missed; so I did not follow up.   'ammobake'  had posted about 3d poly offsets which must have prompted

the email. 

 

Anyway,  I looked into it; and  the error was caused by a civil 3d reference in the vba project.  Back then, I was working  with civil 3d 

objects and code; and evidently left civil 3d references in the  project.   Sorry bout' that.   Not sure why the vba  'StrConv' function would crash with civil 3d

references in the project, but when I removed the civil 3d references,  StrConv  worked as usual. 

 

I tested the code in vanilla autocad 2010 and autocad 2020 and it works. 

 

So I am uploading the new version.

Offset3dPoly.dvb

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...