- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've created a program which works with 2dPolylines.
It reads and print the point of vertexes, the bulge and the radius of the arcs. If the radius one arcs are smaller then 3 the width of this segment will be set up to 1. Program running fine.
But I wanted to work it with polylines too. So I've jut added the convertpoly command. (command "convertpoly" "h" name_Poly "")
The conversation is working but after that the program stops at the second vertex with failure: error: Automation Error. Invalid class
And intresting, in one drawing I have 4 polylines, buy one it is not working but by the other three it is working.
If I create a polyline with arcs in it it works. But if I make a copy and convert it back to polyline again than I get error.
What can be the problem? Why the result is not stable?
(defun c:coord (/ width name_Poly e obj element r bulge p1 p2 L r angARC segmentIndex)
(vl-load-com)
(setq width 1) ;width o the arc segments in the polyline
-------------------------------------------------------------------------------------------
(setq name_Poly (car (entsel)))
(setq e (entget name_Poly))
(if (= (cdr (assoc 0 e)) "LWPOLYLINE")
(progn
(command "pedit" name_Poly "w" "0" "" "")
(command "convertpoly" "h" name_Poly "")
(princ "\nPolyline converted into 2Dpolyline")
(setq e (entget name_Poly))
) ;end progn
) ;end if
;get the parent entity list
(setq obj (vlax-ename->vla-object name_Poly))
; (vlax-dump-object obj T)
(setq segmentIndex -1)
(setq element (fix (+ 1 (vlax-curve-getEndParam obj)))) ;ennyi vertexből áll a ployline
-------------------------------------------------------------------------------------------
(repeat element
(setq segmentIndex (1+ segmentIndex))
(setq e (entget (entnext (cdr (car e)))))
;get the vertex entity list
(if (/= (cdr (assoc 0 e)) "SEQEND")
;if it is not "end-of-sequence
(progn
;do the following
(terpri)
;new line
(setq p1 (cdr (assoc 10 e)))
(setq bulge (cdr (assoc 42 e)))
(princ p1)
;print the co-ordinates
(princ (strcat " bulge = " (rtos bulge)))
;print the bulge
(if (/= bulge 0)
(progn
(setq p2 (cdr (assoc 10 (entget (entnext (cdr (car e)))))))
(setq L (distance p1 p2))
(setq angARC (* 4.0 (atan bulge)))
(setq r (abs (/ (/ L 2) (sin (/ angARC 2.0)))))
(princ (strcat " r = " (rtos r)))
(if (< r 2.99999)
(vla-setwidth obj segmentIndex width width)
(vla-setwidth obj segmentIndex 0 0)
) ;end if
;If radius small then change the width
) ;end progn
) ;end if
) ;progn
) ;if
) ;repeat
(princ)
) ;defun
Solved! Go to Solution.