Jump to content

How do I offset 3d Polyline


free2fly

Recommended Posts

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?

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Joe Kycek

    7

  • seth007

    4

  • ReMark

    3

  • John1951

    3

  • 6 months later...
  • 4 years later...

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

Link to comment
Share on other sites

  • 5 years later...

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

Link to comment
Share on other sites

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

 

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...