Hi folks. Been looking about for an answer this riddle all over and every time I think I have it licked it breaks again.
Background - So I have a drawing with ohhhh 35,000 polylines. Mixed variety. I thought there were some old ones but so far all object names are either "AcDbPolyline", or "AcDb2dPolyline". Unless I missed my guess these are both post R14 polyline types. Many open and many closed. I am developing a program that updates these polylines. In a nutshell the closed donut plines are locations of importance (I cannot say what they are) - and the open polylines are supposed to connect to the centers. Sometimes they dont. That's where I come in.
I tried to use the Pedit command but found out real fast once you do and try to join it it gives the Invalid Class error. I searched and all and started seeing the vla-release-object commands that I thought started to do the trick but I still get the errors even after I place that code after a vla-object grab. As I iterate through surrounding objects its usually ok on the first vlisp action. Its when I get to the second time it needs to be modified again (other endpoint) that even after a release it still generates the class error.
My ssget filter is grabbing all open lw or older polylines with 70.128 or 70.0 flags. Now this thing runs in a different region that has the same mixture of lw and older polylines and runs perfectly over and over and over. I run it in a different section and poof no worky. I have to be missing something. I thought at first it was the 128 vs 0 flag but so far the only thing i know for sure is once ia pline has been acted upon then it becomes the invalid class (t)error suspect. lol. I am going to post some code to illustrate whats going on. I know there are ways to improve the code but I like to line by line sometimes because it helps me understand what I do without going into comment hell. I want to try to focus on why i get the error and how to fix it not my poorly written code
-- Many thanks in advance for help or suggestions. My vars and counters were working properly but in relabeling for this post i may have missed something. I will add comments to sections if someone needs to see intent.
(setq fixit
nil vptlist
nil) (setq fixpline
(nth ifixcnt plines
)) ((member 0.0 templist
)(vertlisterldr templist
)) ((not (member 0.0 templist
))(vertlister templist
)) ) ;formats the coord list how i want it for other code areas
) ;fix for vlax issue of elevation in coords, elevation should all be 0 or reset to 0
;center is the center of the donut obtained earlier
((> e2dist e1dist
)(setq goodend endp1
)) ((> e1dist e2dist
)(setq goodend endp2
)) )
((> gap
700)(setq fixit T
)) ((<= gap
700)(setq fixit
nil)) )
(vl-cmdf "pedit" fixpline
"J" lasty
"" "W" "1200" "") )
((= goodend endp1
)(setq chgvert
(subst center
(car vertlist
) vertlist
))) ((= goodend endp2
)(setq chgvert
(subst center
(last vertlist
) vertlist
))) )
((= elevflag
nil)(setq vptlist
(append vptlist cordx cordy
))) ((= elevflag T
)(setq vptlist
(append vptlist cordx cordy '
(0.0)))) )
)
)
(Princ "Line is already correct \n") )
)
);inner while
In a nutshell:
I have a list of donuts and the plines that go into those donuts.
For every donut and its subsequent plines
Take the plines one by one, and find the correct end
After finding the correct end measure the distance to the donut center
if gap is too big
then make the pline go from the end to the center
else if the gap is not 0
then skooch it over to the center (chg end point to the donut center)
else its ok
the elevation thing surprised me a few points in time and i band-aided it every time.
The elevation is useless and needs to be 0 or set to 0 each time. There is a sub routine vertlister that reformats the coordinates to something i like better for other areas of the program. I unravel it in the foreach statement and tack on an elevation if that's how it came right before i modify the object. I am willing to try most things. I could separate the polylines thereby ruling out whether its the LW or the older plines causing mischief but again its running in another area with mixed lines perfectly.... Closing and re-saving drawing after each edit is out of the question. I sort via enam (which i recently discover does actually change just not while in session). So re-drawing the polylines is a LAST RESORT. I can post some object dumps if need be. Again thanks in advance peeps.