BIGAL Posted June 3, 2018 Posted June 3, 2018 (edited) 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 June 3, 2018 by BIGAL Quote
mariarfd Posted June 3, 2018 Author Posted June 3, 2018 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 Quote
BIGAL Posted June 4, 2018 Posted June 4, 2018 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 ) Quote
Recommended Posts
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.