Florian Posted February 4, 2021 Share Posted February 4, 2021 Hello! I have been getting suggestions and help from this forum for some time now, but have reached a point where I am currently at a loss. I am still relatively new to the topic of lisp and co, but I am trying to improve constantly. For my current problem, I am trying to select a block and insert a point into it. I have simplified my current lisp file into the function below so as not to go over the top. My problem is that I get back an empty selection set and thus can't execute the function from Lee Mac correctly. (defun TestFunction ( / ) (while (= ss NIL) (if (setq ss (ssget "_+.:S:E:L" '((0 . "INSERT")))) (progn (setq ent (ssname ss 0)) (setq Block (vla-item (vla-get-blocks (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (cdr (assoc 2 (entget (ssname ss 0)))))) (Insert_Point) ) ) ) ) (defun Insert_Point ( / ) ;; Block Einfügepunkt ermitteln (setq Message (strcat "\nEinfügepunkt wählen:")) (setq Pnt (getpoint Message)) (setq sel (ssadd)) (setq Point (vla-addpoint Block (vlax-3d-point Pnt))) (ssAdd (vlax-vla-object->ename Point) sel) ;; sel stays empty so the following line cant be executed properly (UpdateBlock doc ent sel) ) Many thanks for your help! Best regards Florian Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 5, 2021 Share Posted February 5, 2021 Give this a try: (defun c:testfunction (/ block doc ent pnt ss) (while (and (setq ss (ssget "_+.:S:E:L" '((0 . "INSERT")))) (setq pnt (getpoint "\nEinfügepunkt wählen:")) ) (progn (setq ent (ssname ss 0)) (setq block (vla-item (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (cdr (assoc 2 (entget ent))) ) ) (vla-addpoint block (vlax-3d-point pnt)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Florian Posted February 8, 2021 Author Share Posted February 8, 2021 Hello! Thank you for your answer I still got a problem, if the block is a dynamic one. When I open the block in Blockeditor or just press attsync all points are gone. How can I handle this problem? Thank you! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 8, 2021 Share Posted February 8, 2021 6 hours ago, Florian said: Hello! Thank you for your answer I still got a problem, if the block is a dynamic one. When I open the block in Blockeditor or just press attsync all points are gone. How can I handle this problem? Thank you! Maybe try this: (defun c:testfunction (/ block doc ent pnt ss) (while (and (setq ss (ssget "_+.:S:E:L" '((0 . "INSERT")))) (setq pnt (getpoint "\nEinfügepunkt wählen:")) ) (progn (setq ent (ssname ss 0)) (setq block (vla-item (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (vla-get-effectivename (vlax-ename->vla-object ent)) ) ) (vla-addpoint block (vlax-3d-point pnt)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Florian Posted February 16, 2021 Author Share Posted February 16, 2021 Hey I still have a problem with updating the new points. They are not visible in my drawing. When I "attsync" the block, they are visible, but if I copy this block in a new drawing, they are totally gone again. Additionally I can not vla-move this point in an other function. Is it possible, I miss some kind of update? Thanks for your time! Best Regards Florian Quote Link to comment Share on other sites More sharing options...
Florian Posted March 1, 2021 Author Share Posted March 1, 2021 Hello Does anyone have an idea, what I am doing wrong here? Quote Link to comment Share on other sites More sharing options...
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.