Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vla-wbock

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Redraiderr2009
1141 Views, 8 Replies

vla-wbock

I am trying to figure out how to covert my traditional selection set to a selection set that vla-wblock would use. 

 

Here is my code:

(if
  (setq Sset (ssget "_X" (list '(0 . "INSERT")(cons 8 "LayerName"))))
  (progn
    (vla-wblock
       "c:\\temp\\testblock"
	Sset
    );_end wblock
  );_end progn
);_end if

 My questions are these:

1. Do i need to add ".dwg" on the end of the location?

2. How do I covert this selection set to the object that autocad needs to use? 

3. Will this vla-wblock overright the block with that same name or do i need to delete the drawing with the same same that is already there first?

8 REPLIES 8
Message 2 of 9
hmsilva
in reply to: Redraiderr2009

Redraiderr2009 wrote:

... My questions are these:

1. Do i need to add ".dwg" on the end of the location?

2. How do I covert this selection set to the object that autocad needs to use?

3. Will this vla-wblock overright the block with that same name or do i need to delete the drawing with the same same that is already there first?

1. no

2.

 

(if
  (setq Sset (ssget "_X" (list '(0 . "INSERT")(cons 8 "LayerName"))))
  (progn
    (setq Sset (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
    (vla-wblock (vla-get-activedocument (vlax-get-acad-object))
       "c:\\temp\\testblock"
	Sset
    )
  );; progn
);; if

 

3. yes it overwrites

 

hope that helps

Henrique

EESignature

Message 3 of 9
Redraiderr2009
in reply to: hmsilva

Most places I look at tell me to do it the way that you have posted, but I still get this error message when selecting the blocks. When I run the routine there are items in the selection set, but because it's a selection set in a variable it may not be the active selection set. 

 

Make a selection of plants:
Select objects: Specify opposite corner: 23 found, 5 groups
Select objects:
Error: Automation Error. Calling method AddItems of interface IAcadSelectionSet
failed
Command: 'VLIDE

Message 4 of 9
hmsilva
in reply to: Redraiderr2009

tested and no errors ...

EESignature

Message 5 of 9
Redraiderr2009
in reply to: hmsilva

Yeah it worked outside the routine. There must have be some conflict with my selection sets. I ended up blanking all the selection sets out before it made this new selection and that did the trick. It was a likttle confusion as to why the last selection set made would not have been the activeselection set. I am willing to live with it. 

Message 6 of 9
hmsilva
in reply to: Redraiderr2009

glad you got a solution

 

Henrique

EESignature

Message 7 of 9
pbejse
in reply to: hmsilva


@hmsilva wrote:
(if
  (setq Sset (ssget "_X" (list '(0 . "INSERT")(cons 8 "LayerName"))))
  (progn
    (setq Sset (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
........

 


 

You need to delete Sset collection.  after processing the selection , (vla-delete Sset) ActiveX is crazy that way.

or prior to selection you can ensure there are no "activeselectionset"  by  "clearing" the collection

 

(setq aDoc  (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for i (vla-get-selectionsets aDoc)
		(vla-delete i))

	(if (ssget "_X" '((0 . "TEXT")))
		(vlax-for i (setq Selset (vla-get-ActiveSelectionSet adoc))
                  	.....)

 

or somethingt to that effect. you get the idea 🙂

 

HTH

Message 8 of 9
hmsilva
in reply to: pbejse

pbejse,

thank you very much, as always, I wrote faster than I used the brain...

 

Cheers
Henrique

EESignature

Message 9 of 9
Hallex
in reply to: Redraiderr2009

To avoid that better yet to use named selection set

I'm personally prefer to use PickFirstSelectionSet

something like this:

(defun C:VWB (/ acapp adoc fcode fdata pfs)
  
(setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))
      
      pfs (vla-get-pickfirstselectionset adoc)
      )
(vla-zoomextents acapp)
  
(vl-catch-all-apply 'vla-clear (list pfs))

 (setq fcode   (vlax-safearray-fill
		 (vlax-make-safearray vlax-vbinteger '(0 . 2))
		 (list 0 8 410)
		 )
       
    fdata  (vlax-safearray-fill
	     (vlax-make-safearray vlax-vbvariant '(0 . 2))
	     (list "text" "ANNO-TEXT" (getvar "ctab")))
       )

(vla-select pfs acselectionsetall nil nil fcode fdata)

(if (> (vla-get-count pfs) 0)
  
(vla-wblock adoc "c:\\test\\wblock_text" pfs )); hard coded, change to suit

  (vla-zoomprevious acapp)
  
  (princ)
  
  )

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost