Jump to content

Add vla-object to selection set


Recommended Posts

Florian

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

Link to post
Share on other sites
ronjonp

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)
)

 

Link to post
Share on other sites
Florian

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!

Link to post
Share on other sites
ronjonp
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)
)

 

Link to post
Share on other sites
Florian

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

Link to post
Share on other sites
  • 2 weeks later...
Florian

Hello :)

 

Does anyone have an idea, what I am doing wrong here?

 

 

Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...