Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
jj26
Posts: 7
Registered: ‎02-05-2013
Message 11 of 30 (616 Views)

Re: Repeat (c:burst) command in lisp routine

02-05-2013 06:43 PM in reply to: Kent1Cooper

I'm testing it on a drawing which has a few blocks and an XREF, I get,

 

'bad argument type: lselsetp <Entity name: 7ed0b988>'

 

when I try and run it. Unfortunately we have to burst the blocks, not explode.

*Expert Elite*
Kent1Cooper
Posts: 5,504
Registered: ‎09-13-2004
Message 12 of 30 (583 Views)

Re: Repeat (c:burst) command in lisp routine

02-06-2013 05:24 AM in reply to: jj26

jj26 wrote:

I'm testing it on a drawing which has a few blocks and an XREF, I get,

 

'bad argument type: lselsetp <Entity name: 7ed0b988>'

 

when I try and run it. Unfortunately we have to burst the blocks, not explode.


My mistake -- (sssetfirst) takes a selection set, not an entity name.  Try replacing this:

 

          (sssetfirst nil blk)

 

with this:

 

          (sssetfirst nil (ssadd blk))

Kent Cooper
Active Member
jj26
Posts: 7
Registered: ‎02-05-2013
Message 13 of 30 (572 Views)

Re: Repeat (c:burst) command in lisp routine

02-06-2013 02:48 PM in reply to: jj26

Works great! Thanks.

Active Contributor
mwhea
Posts: 39
Registered: ‎09-04-2012
Message 14 of 30 (541 Views)

Re: Repeat (c:burst) command in lisp routine

03-06-2013 06:46 PM in reply to: jj26

HI Kent1Cooper

 

(defun Burstzero (/ GoAgain blks blk)
  (vl-load-com)
  (setq GoAgain T)					; to begin with [make at least one pass]
  (while
    (and
      GoAgain						; will be nil once it makes a pass without finding any non-Xref blocks
      (setq blks (ssget "_X" '((0 . "INSERT")))) 	; includes Xref's
    )							; and
     (setq GoAgain nil)					; "zero out" initially for this pass
     (repeat (sslength blks)
       (setq blk (ssname blks 0))			; first [remaining] item in selection
       (if (not	(vlax-property-available-p
		  (vlax-ename->vla-object blk) 'Path))	; i.e. it's not an Xref [ordinary Blocks don't have Path property]
	 (progn
	   (setq GoAgain T)				; it found one, so run the loop again after this pass
	   (sssetfirst nil (ssadd blk))
	   (c:burst)
	 )						; progn
       )						; if
       (ssdel blk blks)					; remove that entity name from selection, go on to next
     )							; repeat
  )							; while
)							; defun

 Your burst fuction is really helpful taking out the xrefs from the burst function of the while loop, though after testing this for over a month i have noticed some drawings having problems with this function and asking the user to select objects.

 

Command: 0 found

Select Objects:

 

I thought it was to do with non exploading blocks but i have run another routine to sort through all blocks to be exploadable. When i do a ssx (entity) insert i am returned with 97 found - would you understand what is going on??

 

Cheers

Mark

 

 

Active Contributor
mwhea
Posts: 39
Registered: ‎09-04-2012
Message 15 of 30 (535 Views)

Re: Repeat (c:burst) command in lisp routine

03-06-2013 07:11 PM in reply to: mwhea

If you processed the command by continuously hitting Enter it started running the routine but there was 4 objects still left i could select using ssx insert. These objects were on the Layout1 tab, is my assumption correct that ssx actually looks at all tabs model,layout and returns but because we are working in model space it cant actually run the burst routine on the blocks located in the layout tab and then causes this error in making the lisp routine fail?

 

My easy solution was to just to have the routine remove everything from layout space - though is there a way to avoid this?? 

 

 

*Expert Elite*
Kent1Cooper
Posts: 5,504
Registered: ‎09-13-2004
Message 16 of 30 (519 Views)

Re: Repeat (c:burst) command in lisp routine

03-07-2013 05:46 AM in reply to: mwhea

mwhea wrote:

If you processed the command by continuously hitting Enter it started running the routine but there was 4 objects still left i could select using ssx insert. These objects were on the Layout1 tab, is my assumption correct that ssx actually looks at all tabs model,layout and returns but because we are working in model space it cant actually run the burst routine on the blocks located in the layout tab and then causes this error in making the lisp routine fail?

 

My easy solution was to just to have the routine remove everything from layout space - though is there a way to avoid this??


I'm not positive about Burst, but I know that at least for native AutoCAD editing commands, only things in the current space are recognized in object selection, so for example, Explode would not be able to do its thing to Blocks in a paper space Layout when you're in model space.  If that's the issue with Burst too, try having the routine go into the space each object is in, so it can Burst it:

....

    (repeat (sslength blks)
      (setq blk (ssname blks 0))
      (if (not (vlax-property-available-p (vlax-ename->vla-object blk) 'Path))
        (progn
          (setq GoAgain T)

          (setvar 'ctab (cdr (assoc 410 (entget blk))))

          (sssetfirst nil (ssadd blk))
          (c:burst)
        ) ; progn
      ) ; if
      (ssdel blk blks) ; remove that entity name from selection, go on to next
    ) ; repeat

....

 

You can add a (setvar 'ctab "Model") at the end, if you like, or even save the current tab [whether model space or any paper space Layout] at the beginning, and return to it at the end.

Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,504
Registered: ‎09-13-2004
Message 17 of 30 (515 Views)

Re: Repeat (c:burst) command in lisp routine

03-07-2013 06:13 AM in reply to: mwhea

mwhea wrote:

.... When i do a ssx (entity) insert i am returned with 97 found - would you understand what is going on??

....


[I'm not familiar with "ssx" but I assume that by "ssx (entity) insert" you mean (ssget "_X" '((0 . "INSERT"))).]

 

The "INSERT" entity type applies not only to Blocks and Xrefs, but also to some entity types that a lot of people may not use much -- those produced by MINSERT [Multiple-insert (insert-and-array) Blocks], WMFIN [Windows Metafiles], LIGHT [light sources, which may be in my Architectural Desktop but perhaps not in vanilla AutoCAD or some other overlays], and in rather older versions of AutoCAD, HATCH [before a Hatch pattern was an entity type of its own, it was a special kind of Block].  Using (ssget) with a filter for "INSERT" entity type will find all of those.
 

Some of those can be Exploded [Hatch patterns at least], though I don't know whether Burst works on all of them.  And some can't [Minserts at least], so I assume Burst would not work on them, either.  So if you have any of those un-Burstable kinds of entities in the drawing, the routine will continue to find them.

 

If you never use those things, the problem must be something else, but if you do, you would need to build in additional checks on the sub-entity-type.  An old-style Hatch pattern has a "Block name" beginning with "*X"; a Windows Metafile has a "Block name" beginning with "WMF" [though they can be renamed, so that's not foolproof], Lights have a limited number of specific Block names, and Minserts can be identified by their entity data's second (assoc 100) entry [the following returns T]:
(= (cdr (assoc 100 (reverse EntityData))) "AcDbMInsertBlock").

 

By the way, I've since discovered a more concise way to identify an Xref as distinct from a Block:

(assoc 1 (tblsearch "block" BlockName))

returns T for an Xref, and nil for a Block.  Ordinary Blocks do not have an (assoc 1) entry in their Block table information, but Xrefs do -- it's the filepath and name, so it's just a shorter way to check whether it has a Path, as the routine currently does in a longer way by looking at whether it has the 'Path VLA property.

Kent Cooper
Active Contributor
mwhea
Posts: 39
Registered: ‎09-04-2012
Message 18 of 30 (506 Views)

Re: Repeat (c:burst) command in lisp routine

03-07-2013 03:04 PM in reply to: jj26

Yeah sorry i always thoguht ssx was the alternative to ssget because it comes up with the same functions (ssx entity = 0 . INSERT) 

 

The routine is for cleaning architectural files up so each architect is different in the way they produce drawings so there is no knowing what could b in the file. Saying that however i have never come accross a WMFIN file or LIGHT and all the architects we work with have later versions so the HATCH isn't a issue. I did some further reading yesterday and added this to the lisp routine

 

      (setq blks (ssget "_X" '((0 . "INSERT") (67 . 0) (410 . "Model")))) ; includes Xref's

 

Though i'll problaby use what you have pasted in blue. 

 

Is there any advantage over using the new method of finding the xrefs? or just to neaten the code up a bit as i am not very good with writing lisp routines so i wouldn't know where to insert the (assoc 1 (tblsearch "block" BlockName)) 

 

Also because MINSERT cannot be burst would it be worth to expload that once then the blocks used for the mutliple array could be bursted?

 

Cheers

Mark

*Expert Elite*
Kent1Cooper
Posts: 5,504
Registered: ‎09-13-2004
Message 19 of 30 (498 Views)

Re: Repeat (c:burst) command in lisp routine

03-07-2013 04:39 PM in reply to: mwhea

mwhea wrote:
.... I did some further reading yesterday and added this to the lisp routine

 

      (setq blks (ssget "_X" '((0 . "INSERT") (67 . 0) (410 . "Model")))) ; includes Xref's

 

Though i'll problaby use what you have pasted in blue. 

 

Is there any advantage over using the new method of finding the xrefs? .... i wouldn't know where to insert the (assoc 1 (tblsearch "block" BlockName)) 

 

Also because MINSERT cannot be burst would it be worth to expload that once then the blocks used for the mutliple array could be bursted?

....


If you do filter for Insert objects only in Model space, you might want to add a line before your (setq blks... line, to make sure you're in Model space so the routine can Burst things it finds there:

(setvar 'ctab "Model")

 
The only "advantages" [if one even considers them to be, really] to the alternative way of determining whether an Insert object is an Xref are: 1) that it uses a little less code; and 2) that in this case, it eliminates the use of any (vl...) functions, so you wouldn't need to do the (vl-load-com) thing.  You would replace this line:

 

      (if (not (vlax-property-available-p (vlax-ename->vla-object blk) 'Path))

 

with this:

 

      (if (not (assoc 1 (tblsearch "block" BlockName)))

 

You can't Explode an Minsert object, unless that capability has been added in a later version than mine.  I expect a Search of this Discussion Group might turn up a way to do break one up, but I haven't searched myself.

Kent Cooper
Active Contributor
mwhea
Posts: 39
Registered: ‎09-04-2012
Message 20 of 30 (465 Views)

Re: Repeat (c:burst) command in lisp routine

03-12-2013 05:47 PM in reply to: jj26

Kent, one last thing about this lisp routine. Will this fail if the selection set of blocks is greater then the maximum allowed by AutoCAD (32767) ?? Only reason i ask is that some times the routine just holds and seems to freeze autocad on larger drawings and this is the only reason i can think behind it?

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.