Jump to content

coordinates extraction per polyline, together with hyperlink text


mariarfd

Recommended Posts

This is an example depending on object

 

; pline co-ords example

(defun plinecords ( / xyz obj i  co-ords )

; program starts here
(setq co-ordsxy '())

(setq obj (vlax-ename->vla-object(car (entsel "\nPlease pick pline"))))

(cond 
( (= (vla-get-ObjectName obj) "AcDbPolyline")(setq xyz 2))
( (= (vla-get-ObjectName  obj)"AcDbLine")     (setq  xyz 1))
( (= (vla-get-ObjectName  obj)"AcDb3dPolyline")(setq xyz 3))
((alert  "Object not supported\n\nPlease pick again"))
)

(if (> xyz 1)
(progn
(setq co-ords
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   obj
   "Coordinates"
     )
   )
 )
 )
 )
 )

(if (= xyz 1)
(progn
(setq xyz(vlax-safearray->list (vlax-variant-value (vla-get-startpoint obj))))
(setq co-ordsxy (cons xyz co-ordsxy))
(setq xyz(vlax-safearray->list (vlax-variant-value (vla-get-endpoint obj))))
(setq co-ordsxy (cons xyz co-ordsxy))
)
)

(if (= xyz 2)
(progn
(setq I 0)
(repeat (/ (length co-ords) 2)
(setq xyz (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xyz co-ordsxy))
(setq I (+ I 2))
)
)
)

(if (= xyz 3)
(progn
(setq I 0)
(repeat  (/ (length co-ords)3)
(setq xyz (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
(setq co-ordsxy (cons xyz co-ordsxy))
(setq I (+ I 3))
)
)
)

)

(plinecords)

Edited by BIGAL
Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • mariarfd

    10

  • hanhphuc

    6

  • BIGAL

    3

  • Tharwat

    3

Greatfull Bigal,

Do you think I would be able to ulter this in order to make it choose many coordinates an once?

Maybe I could try and put something like (ssget "X") in order to do that? (allthought I believe it doesnot work this way and I will mess up)

 

So have been trying to do 2 different lisps

- one for handle+coords

- one for handle+layer+area+perimeter

as this seems easier.

 

so far using your code hanhphuk, as a base, for the second lisp. Each time I run it it returns results for 88 out off 210 polys, I delete some polys and then I get results for 17 out of 37 ... I thought maybe there is something wrong with poly type, checked in list and all of them are lwpolylines. Then tried to erase the layer filter, in case there is something there, same again. Can you think of what might be wrong and please point me some direction?

 

Again, thank everyone for taking the time to help me,

maria

Link to comment
Share on other sites

You are correct can change the method to use a ssget to make a selection set and pass obj to plinecords. Just change the defun line and call it from a repeat.

(defun plinecords ( obj / xyz  i  co-ords )
; or erase this line 
(setq obj (vlax-ename->vla-object(car (entsel "\nPlease pick pline"))))

(setq ss (ssget)) ; add filters etc just pick objects for testing
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))
(plinecords obj)
; the variable co-ordsxy contains a list of 2d or 3d points.
; do your thing here
)

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