Jump to content

VBA-Offset problem


tralles

Recommended Posts

hi,

 

I've a problem. I want to make the polyline offset and would like to know the coordinates of the new polyline.

I write codes, picked the polyline and offset that given distance but dont learn coordinates new poyline.

please help.

Link to comment
Share on other sites

In your VBA code declare a variable for your polyline and set it to your polyline. This polyline object then has an offset method which creates a new polyline object as a variant object. You can then list the coordinates of the new polyline object.

Link to comment
Share on other sites

Here is a co-ords of pline I have changed the code to use last entity created.

 

(defun getcoords (ent)

 (vlax-safearray->list

   (vlax-variant-value

     (vlax-get-property

   (vlax-ename->vla-object ent)

   "Coordinates"

     )

   )

 )

)



(defun co-ords2xy (I numb xy)

; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z

(setq numb (/ (length co-ords) 2))

(setq I 0)

(repeat numb

(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))

(setq co-ordsxy (cons xy co-ordsxy))

(setq I (+ I 2))

)

)



; program starts here

;(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(setq co-ords (getcoords (car (entlast))))
(co-ords2xy)

Link to comment
Share on other sites

thanks for all,

i write that codes for review. first polyline cordinates ok. but i cant learn new polyline.

I want draw third polyline between first polyline first vertex and second polyline last vertex

 

 

Private Sub CommandButton1_Click()

Dim basePnt As Variant

Dim returnObj As AcadObject

Dim distance As Double

Dim vertexPts As Variant

Dim numberofvertices As Long

 

On Local Error GoTo err 'On Error Resume Next

UserForm1.hide

ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select Polyline"

distance = 50 'for example

returnObj.Offset (distance)

vertexPts = returnObj.Coordinates

numberofvertices = UBound(vertexPts) + 1

For i = 0 To numberofvertices - 1 Step 2

MsgBox "" & vertexPts(i) & ", " & vertexPts(i + 1)

Next i

UserForm1.show

Exit Sub

 

err:

If err.Number = -2147352567 Then

UserForm1.show

End If

End Sub

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