Kycau Posted 2 hours ago Posted 2 hours ago Hello. I have a multileader entity. I want to add additional leaders to my multileader. acadObj is the ActiveX object of my multileader. This is how I made it work for me: (setq muu_lead_vert_new_indx (vla-AddLeader acadObj)) (setq muu_lead_vertices_new (vlax-make-safearray vlax-vbdouble '(0 . 8))) (vlax-safearray-fill muu_lead_vertices_new (list pt1 pt2 pt3)) (vla-AddLeaderLine acadObj muu_lead_vert_new_indx muu_lead_vertices_new) It pretty much does the trick, but not as neat as I want it. If I add multiple leaders, and then I want to work with the new leaders... I search for new leaders via: (vlax-invoke acadObj 'getleaderlineindexes 0) (vlax-invoke acadObj 'getleaderlineindexes 1) but 1st command returns '(0), and the second one returns '(1), even if I already have 5 or 8 or 10 leaders on my multileader. An ugly way around that I found, is the following: (setq sbe_ml_indxlist (vl-sort (append (vlax-invoke acadObj 'getleaderlineindexes 0) (vlax-invoke acadObj 'getleaderlineindexes 1)) '<)) (and (/= (length sbe_ml_indxlist) (vla-get-LeaderCount acadObj)) (foreach memb '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda (x) (vla-GetLeaderIndex acadObj x)) (list memb)))) (setq sbe_ml_indxlist (append sbe_ml_indxlist (list memb)))))) The idea is: I make a list of leader indexes (first 2 lines). In my code I have more lines prior to it... with some verifications... but the idea is that sbe_ml_indxlist in first 2 lines should get all existing leader line indexes. Next 4 lines, check: If leader indexes added via vla-AddLeaderLine do not end in the list composed by getleaderlineindexes, I check 1 by 1, if a leader with index X exists, it adds that index to the list of existing indexes. There are still many problems... I don't want to get into too much detail... because my post is not about "solving 20 problems"... which result from damaging the multileader entity... My post is about: "please tell me the right way to add leaders to existing multileader" Some of extra-problems with multileader on which I did run vla-AddLeader, just fyi: 1. One time I had a multileader with 10+ leaders, but vla-get-leadercount showed 8 leaders. After I copied the multileader, the new one was returning 7 from vla-get-leadercount. 2. If I add leaders via (command "_.mleaderedit" entname "A" $ pause), than the ones added to the left of multileader are seen via getLeaderLineIndexes but the ones added to the right are not seen. 3. Once I had a case that getLeaderLineIndexes did not return 0-index leader... but (getLeaderIndex acadObj 0) showed that such a leader exists, but I can't recreate it. 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.