I am having a problem with the "align" command, apparently it can only process 124 entities in a loop then it ignores the other entities. To test this start a new drawing, draw at least 125 arcs in the drawing and run the following code. The program processes 124 arcs and then ignores the rest. Does anybody know how to fix this? (defun c:align_arcs () (setq ent (entnext) counter 1 ) (if (not (member "geom3d.arx" (arx))) (arxload "geom3d.arx") ) (while ent (prompt (strcat "\rProcessing arc #" (rtos counter 2 0)) ) (setq ent2 (entget ent) start_center (list (car (dxf 10 ent2)) (cadr (dxf 10 ent2))) radius (dxf 40 ent2) start_angle (dxf 50 ent2) end_angle (dxf 51 ent2) arc-angle (- end_angle start_angle) start_point (polar start_center start_angle radius) end_point (polar start_center end_angle radius) ) (align ent start_point (list (cadr start_point) (car start_point)) end_point (list (cadr end_point) (car end_point)) "" "Y" ) (setq counter (1+ counter)) (setq ent (entnext ent) ) ) (princ) ) (defun dxf (dxf_code entity_list) (cdr (assoc dxf_code entity_list)) ) Regards/Jon
Jon, The problem seems to be each pass of the align function within the while loop creates a new selection set. When it hits 128, the maximum number of selection sets, it stops. I've run a few tests to verify. Open file containing 170 arcs and nothing else. Load and run your program. 128 arcs are aligned. The rest are not. At this point, select some of the arcs. Properties reports, "No selection". IOW, the application can't create a new selection set. I'm not sure how to fix the problem. Maybe someone else here knows. Or maybe the align function within geom3d.arx is at fault for not releasing each selection set it creates. Joe Burke entities in a loop then it ignores the other entities. following code. The program processes 124 arcs and then ignores the rest.
Dear Joe You are probably right regarding the selection sets, the program I posted is a part of a larger program that uses selection sets and lately I have been getting an error regarding maximum selections sets being reached but I did not link it to the align command but the selection sets I used - this explains a lot but I am not sure how to fix it and still use the align loop. Hopefully someone has the answer, or Autodesk has a fix for the align function! Regards/Jon
Jon, The fact you are seeing an error regarding, "maximum selection sets" tends to confirm the theory behind the problem. I know, the function you posted does not return this error by itself. Seems to me there should be some way to clear/delete the previous selection set. But the problem may be you are calling an external function. Have you tried using (command "align" ...? I wonder if that would work different compared to calling the align function directly from geom3d.arx? Joe Burke of a larger program that uses selection sets and lately I have been getting an error regarding maximum selections sets being reached but I did not link it to the align command but the selection sets I used - this explains a lot but I am not sure how to fix it and still use the align loop.
Dear Joe If I use the (command "align"... AutoCAD crashes with the error that commands can only be nested 4 deep so the external command (align... has to be used. I have been going through several remedies I found in the discussion group to clear selection sets but none of them works, so I guess "align" does not use conventional selection sets that can be cleared by code???? Regards/Jon
Jon, I think I found a solution. Pass ent to align in a selection set. Funny fix, hugh. Joe Burke (defun c:align_arcs2 ( / ent counter ss ent2 start_center radius start_angle end_angle arc_angle start_point end_point ) (setq ent (entnext) counter 1 ) (if (not (member "geom3d.arx" (arx))) (arxload "geom3d.arx") ) (while ent (prompt (strcat "\rProcessing arc #" (rtos counter 2 0)) ) (setq ss (ssadd)) ;added (ssadd ent ss) ;added (setq ent2 (entget ent) start_center (list (car (dxf 10 ent2)) (cadr (dxf 10 ent2))) radius (dxf 40 ent2) start_angle (dxf 50 ent2) end_angle (dxf 51 ent2) arc-angle (- end_angle start_angle) start_point (polar start_center start_angle radius) end_point (polar start_center end_angle radius) ) ;(align ent ;revised (align ss start_point (list (cadr start_point) (car start_point)) end_point (list (cadr end_point) (car end_point)) "" "Y" ) (setq counter (1+ counter)) (setq ent (entnext ent) ) ) ;while (princ) ) ;end only be nested 4 deep so the external command (align... has to be used. selection sets but none of them works, so I guess "align" does not use conventional selection sets that can be cleared by code????
Hi Joe, I guess this is just a test command? wouldn't it have problem if anything other than arcs were in the dwg? ;no testing for 'arcness' ? ; clever use of ssadd in a loop to clear and reset a selection set - i didn't know that would work but I tried it and it does - cool by the way, who's Hugh? Mark
Joe I tested your patch and it worked perfectly, many thanks! To MP: You are right - this is just a test function. It is a part of a subroutine that is only passed arcs in a larger program that recalculates coordinates of all entities in the drawing (that is why I can't be bothered with comments or local variables...). When searching for bugs, such as this one in the align command, I often simplify the code to eliminate options as in this case. Jon
Jon, You're welcome. Glad to hear it worked on your end. BTW, regarding local vars, I appreciate what you said. Just keep in mind, not declaring local vars sometimes leads additional debugging problems. Particularly if a sub-function uses append or cons to create or manipulate a list. Then again, maybe you are handling the symbols created by sub-functions in the calling function. That's something I try avoid whenever possible. IOW, design the sub-functions to return what they are designed to do, or nil if they fail. Regards Joe Burke only passed arcs in a larger program that recalculates coordinates of all entities in the drawing (that is why I can't be bothered with comments or local variables...). the code to eliminate options as in this case.