Help Needed ...

Help Needed ...

Anonymous
Not applicable
142 Views
1 Reply
Message 1 of 2

Help Needed ...

Anonymous
Not applicable
Hi All,

I am writing a program to assign elevation to the entities by fence selection. I am very near to finish my code but I have a problem which really made me exhaust.
Please take a look for my code below:
***********************************************
(defun c:el()
(setvar "osmode" 0)
(setq pt1 (getpoint "Please pick starting point of fence:"))
(command "pline" pt1 pause "")
(setq FstEnt (entlast)
FstEnt1 (vlax-ename->vla-object FstEnt)
pt2 (vlax-curve-getEndPoint FstEnt1))
(command "select" "f" pt1 pt2 "" "r" fstent "")
(setq sset (ssget "p" ' ((0 . "lwpolyline,polyline")))
n 0
NxtEnt (ssname sset n)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
list1 (list dist1))
(repeat (- (sslength sset) 1)
(setq n (+ 1 n)
NxtEnt (ssname sset n)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
list2 (list dist1)
list1 (append list1 list2))
)
(setq list1 (vl-sort list1 '<)
elemcount 0)
(repeat (sslength sset)
(setq listcount 0)
(repeat (sslength sset)
(setq NxtEnt (ssname sset listcount)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
elem1 (nth elemcount list1))
(if (= elem1 dist1)
(progn
(command "change" NxtEnt "" "p" "c" (+ elemcount 1) "")
);end progn
);end if
(setq listcount (+ 1 listcount))
);repeat
(setq elemcount (+ 1 elemcount))
);repeat
(entdel FstEnt)
)
I have used GETINTERS to get intersection points.
*********************************************************
Now my problem is.... when I am changing the color of entities, its working fine but as I started assigning elevation to them, it shows error. I have tried change command & entmod for elevation assigning.
Please suggest me where I am wrong.
thanks
0 Likes
143 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hi Kashuuu,
Your code need others function,like this and I hope this code can help you

(setq es1 (car (entsel "\nSelect a first line")))
(setq es2 (car (entsel "\nSelect a second line")))

(setq intersection_point (car (GetInters es1 es2 acExtendNone)))

(defun GetInters (firstobj nextobj mode / coord ptlst) ; by Joe
Burke
(vl-load-com)
(if
(= (type firstobj) 'ENAME)
(setq firstobj (vlax-ename->vla-object firstobj))
)
(if
(= (type nextobj) 'ENAME)
(setq nextobj (vlax-ename->vla-object nextobj))
)
(and
(setq coord (vlax-invoke firstobj 'IntersectWith nextobj mode))
(repeat
(/ (length coord) 3)
(setq ptlst (cons (list (car coord) (cadr coord) (caddr coord))
ptlst))
(setq coord (cdddr coord))
)
)
(reverse ptlst)
) ;end

wrote in message news:5138572@discussion.autodesk.com...
Hi All,

I am writing a program to assign elevation to the entities by fence
selection. I am very near to finish my code but I have a problem which
really made me exhaust.
Please take a look for my code below:
***********************************************
(defun c:el()
(setvar "osmode" 0)
(setq pt1 (getpoint "Please pick starting point of fence:"))
(command "pline" pt1 pause "")
(setq FstEnt (entlast)
FstEnt1 (vlax-ename->vla-object FstEnt)
pt2 (vlax-curve-getEndPoint FstEnt1))
(command "select" "f" pt1 pt2 "" "r" fstent "")
(setq sset (ssget "p" ' ((0 . "lwpolyline,polyline")))
n 0
NxtEnt (ssname sset n)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
list1 (list dist1))
(repeat (- (sslength sset) 1)
(setq n (+ 1 n)
NxtEnt (ssname sset n)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
list2 (list dist1)
list1 (append list1 list2))
)
(setq list1 (vl-sort list1 '<)
elemcount 0)
(repeat (sslength sset)
(setq listcount 0)
(repeat (sslength sset)
(setq NxtEnt (ssname sset listcount)
pntlst (car (GetInters FstEnt NxtEnt))
dist1 (distance pt1 pntlst)
elem1 (nth elemcount list1))
(if (= elem1 dist1)
(progn
(command "change" NxtEnt "" "p" "c" (+ elemcount 1) "")
);end progn
);end if
(setq listcount (+ 1 listcount))
);repeat
(setq elemcount (+ 1 elemcount))
);repeat
(entdel FstEnt)
)
I have used GETINTERS to get intersection points.
*********************************************************
Now my problem is.... when I am changing the color of entities, its working
fine but as I started assigning elevation to them, it shows error. I have
tried change command & entmod for elevation assigning.
Please suggest me where I am wrong.
thanks
0 Likes