Jump to content
ThatGermanFool

Using cutlclip and pasteclip for block definition

Recommended Posts

ThatGermanFool

Hi guys,

 

I'm wondering whether it is possible to use cutlclip and pasteclip for block Definition in Lisp.

Normally, I would use an empty block, some attdefs, an endblk and entmake the objects I got with ssget in between. Afterwards, I'd delete the whole ssget selection set and insert the block instead.

;; create empty block
(entmake (list 
			(cons 0 "INSERT")
			(cons 2 blname)
			(cons 70 66)
			(cons 10 pIns)
		 )
) ;; end entmake

[ENTMAKE OBJECTS HERE]

(entmake (list (cons 0 "ATTDEF")[...])) 

;; set end of block
(entmake (list (cons 0 "ENDBLK")))

As entmaking inserts or polylines etc. is some work, I'd like to know if and how I  could use pasteclip instead.

 

Hope, my question is not that confusing.

 

Cheers, Seb

Share this post


Link to post
Share on other sites
ronjonp

Perhaps try using THIS.

Share this post


Link to post
Share on other sites
ThatGermanFool
14 hours ago, ronjonp said:

Perhaps try using THIS.

Hi ronjonp, thank you for your answer, but the thread seems to be inaccessible to me :(

"The topic or board you are looking for appears to be either missing or off limits to you."

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)
6 hours ago, ThatGermanFool said:

Hi ronjonp, thank you for your answer, but the thread seems to be inaccessible to me :(

"The topic or board you are looking for appears to be either missing or off limits to you."

Attached is the code from TheSwamp. You should create an account there though ... lots of smart peeps there :).

EntMaker CAB 05- MakeEntmake.lsp

Edited by ronjonp
  • Thanks 1

Share this post


Link to post
Share on other sites
ThatGermanFool

Thank you! It is not what I needed (I need to process nested blocks as well). 

But I'll consider signing up for the Swamp :)

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

Do you have to use entmake? Here is a simple example to add selected objects to a block using vla.

(defun c:foo (/ a b s)
  (setq a (vla-get-activedocument (vlax-get-acad-object)))
  (setq b (vla-add (vla-get-blocks a) (vlax-3d-point '(0. 0. 0.)) "MyNewBlock"))
  ;; (vlax-for x b (vla-delete x))
  (and (setq s (ssget))
       (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))
       (vlax-invoke a 'copyobjects s b nil)
  )
  (princ)
)
(vl-load-com)

 

Edited by ronjonp
  • Thanks 1

Share this post


Link to post
Share on other sites
ThatGermanFool
5 minutes ago, ronjonp said:

Do you have to use entmake? Here is a simple example to add selected objects to a block using vla.


(defun c:foo (/ a b s)
  (setq a (vla-get-activedocument (vlax-get-acad-object)))
  (setq b (vla-add (vla-get-blocks a) (vlax-3d-point '(0. 0. 0.)) "MyNewBlock"))
  ;; (vlax-for x b (vla-delete x))
  (and (setq s (ssget))
       (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))
       (vlax-invoke a 'copyobjects s b nil)
  )
  (princ)
)
(vl-load-com)

 

That looks like it could work. Thank you for pointing that out! I always forget that the visual Lisp functions are pretty powerful. Will try it later and report back to you :)

Share this post


Link to post
Share on other sites
ThatGermanFool

 

This is what I needed.

I came up with a combination of Copybase and Pasteblock and then modifying attributes with visual Lisp. Thanks for the hint tho.

(vl-load-com)

;; prompt block name
(setq blname (getstring "SAY MY NAME!\n"))

;; prompt remark (optional)
(setq remark (getstring "Who is the one who knocks? (optional)\n"))

;; prompt objects to include
(setq blockSelection (ssget))

;; prompt insertion point
(setq pIns (getpoint "What's the point?\n"))

;; copy to block
(command "_.COPYBASE" pIns blockSelection "")
(command "_.PASTEBLOCK" pIns)

;; change name
(vla-put-name (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (cdr (assoc 2 (entget (entlast))))) blname)

;; add attributes
(setq item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blname))


;; Name
(vla-addattribute
   item
   400
   (+ acattributemodelockposition acAttributeModeInvisible)
   "name"
   (vlax-3D-point 0 0 0)
   "name"
   blname
)

;; Remark
(vla-addattribute
   item
   400
   (+ acattributemodelockposition acAttributeModeInvisible)
   "remark"
   (vlax-3D-point 0 0 0)
   "remark"
   remark
)

;; update block with attribute
(command "_.attsync" "_N" blname)

;; erase selection
(command "_erase" blockSelection "")

Share this post


Link to post
Share on other sites
ronjonp

Glad you got it sorted!

Share this post


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.   Paste as plain text instead

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