Author Topic: LISP to access Block level outside of another block of a clicked entity?  (Read 9372 times)

0 Members and 1 Guest are viewing this topic.

ctrlaltdel

  • Guest
As per topic, I am looking for a LISP to do this:-

Block 1 (Outer most block)<<<<Block 2<<<<Block 3<<<<Block 4<<<<Block 5<<<<Block 6<<<<Block 7 (inner/deepest most block)

When run the lisp, cadder will click on an entity (which happens to be in Block 6) & the lisp will bring the cadder to Block 5 in the Block In-Place command.

Cheers

ctrlaltdel

  • Guest
This will best explain my requirement

Attached is a simplified drawing. All are blocks. The 4 square share the same block name but are nested in different block.

I need to
- get into the correct block level
- explode lower right square block
- move the lower right side square just below the upper right square
- delete the lower entity of the square as per in the photo
*All blocks still need to remain as per their original block integrity except 1 of the square block that was exploded

I have tried -refedit in the below drawing for at least 30 minutes but still unable to go to the right block level to do the above.

That is why I would be glad for a LISP that can get me straight into the correct block level.

Thanks
« Last Edit: August 20, 2016, 07:04:31 AM by ctrlaltdel »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Block 1 (Outer most block)<<<<Block 2<<<<Block 3<<<<Block 4<<<<Block 5<<<<Block 6<<<<Block 7 (inner/deepest most block)

When run the lisp, cadder will click on an entity (which happens to be in Block 6) & the lisp will bring the cadder to Block 5 in the Block In-Place command.

Perhaps something like this?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:myblockedit ( / lst )
  2.     (if (setq lst (cadddr (nentsel)))
  3.         (command "_.bedit" (cdr (assoc 2 (entget (cond ((cadr lst)) ((car lst)))))))
  4.     )
  5.     (princ)
  6. )

ctrlaltdel

  • Guest
Block 1 (Outer most block)<<<<Block 2<<<<Block 3<<<<Block 4<<<<Block 5<<<<Block 6<<<<Block 7 (inner/deepest most block)

When run the lisp, cadder will click on an entity (which happens to be in Block 6) & the lisp will bring the cadder to Block 5 in the Block In-Place command.

Perhaps something like this?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:myblockedit ( / lst )
  2.     (if (setq lst (cadddr (nentsel)))
  3.         (command "_.bedit" (cdr (assoc 2 (entget (cond ((cadr lst)) ((car lst)))))))
  4.     )
  5.     (princ)
  6. )

Thanks Lee Mac.

Yes & No.

Yes, it got into the correct block, But No, cause I need to be in the "Block in-place"/refedit mode cause I need to see All the other block as a reference for me.

I hope you know what I am getting at & have a solution?

Crossing Fingers.
« Last Edit: August 20, 2016, 09:24:02 AM by ctrlaltdel »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Maybe this:
Code: [Select]
(defun c:test ( / nentselLst nestLevel)
  (if
    (and
      (setq nentselLst (nentsel))
      (= 4 (length nentselLst))
      (<= 0 (setq nestLevel (- (length (cadddr nentselLst)) 2)))
    )
    (progn
      (setvar 'cmdecho 0)
      (command "_.-refedit" (list (last (cadddr nentselLst)) (cadr nentselLst)))
      (repeat nestLevel (command "_next"))
      (command "_ok" "_all" "_yes")
      (setvar 'cmdecho 1)
    )
  )
  (princ)
)

ctrlaltdel

  • Guest
Thanks roy_043.

Ran the LISP but an error occur

Quote
Command: test
Select object:
*Invalid selection*
Expects a single object.
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
Select reference: *Cancel*
Command: *Cancel*

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
The code works fine on BricsCAD. Because command calls are used it may need to be tweaked to run on AutoCAD. Since I do not have an AC license I cannot help with that.

ctrlaltdel

  • Guest
The code works fine on BricsCAD. Because command calls are used it may need to be tweaked to run on AutoCAD. Since I do not have an AC license I cannot help with that.

 :cry:

Regardless, still thousands thanks for the help roy_043

 :cry:

ctrlaltdel

  • Guest
Quote
Block 1 (Outer most block)<<<<Block 2<<<<Block 3<<<<Block 4<<<<Block 5<<<<Block 6<<<<Block 7 (inner/deepest most block)

When run the lisp, cadder will click on an entity (which happens to be in Block 6) & the lisp will bring the cadder to Block 5 in the Block In-Place command.

Perhaps something like this?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:myblockedit ( / lst )
  2.     (if (setq lst (cadddr (nentsel)))
  3.         (command "_.bedit" (cdr (assoc 2 (entget (cond ((cadr lst)) ((car lst)))))))
  4.     )
  5.     (princ)
  6. )

Thanks Lee Mac.

Yes & No.

Yes, it got into the correct block, But No, cause I need to be in the "Block in-place"/refedit mode cause I need to see All the other block as a reference for me.

I hope you know what I am getting at & have a solution?

Crossing Fingers.

Lee Mac Sir, you have solution for LISP to enter "Block in-place"/refedit mode instead of bedit?

ctrlaltdel

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #9 on: September 02, 2016, 02:03:11 AM »
I amended the code in this manner
Code: [Select]
    (defun c:myblockedit ( / lst )
        (if (setq lst (cadddr (nentsel)))
            (command "_.refedit" (cdr (assoc 2 (entget (cond ((cadr lst)) ((car lst)))))))
        )
        (princ)
    )
But encounter this error after clicking the entity
Quote
Command: MYBLOCKEDIT

Select object: _.refedit
Select reference: 5 Reference not found

How to make it work correctly?
« Last Edit: September 02, 2016, 02:09:03 AM by ctrlaltdel »

danallen

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #10 on: September 02, 2016, 09:25:50 AM »
what is returned when you enter at command and select the block?
Code - Auto/Visual Lisp: [Select]
[/code]

ctrlaltdel

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #11 on: September 02, 2016, 12:42:02 PM »
what is returned when you enter at command and select the block?

Quote
Command: MYBLOCKEDIT

Select object: _.refedit
Select reference: 5 Reference not found
Select reference:    <<<<it went straight to a usual refedit command, cause when i click the same entity, the reference edit dialog box appear
« Last Edit: September 02, 2016, 12:48:32 PM by ctrlaltdel »

danallen

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #12 on: September 02, 2016, 03:47:38 PM »
I'll try again, what happens when you type (nentsel) and pick the block? This would tell you/us how many nested entities exist
Code - Auto/Visual Lisp: [Select]

ctrlaltdel

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #13 on: September 02, 2016, 09:52:43 PM »
I'll try again, what happens when you type (nentsel) and pick the block? This would tell you/us how many nested entities exist
Code - Auto/Visual Lisp: [Select]



Quote
Command: (nentsel)

Select object: (<Entity name: 7ffffb163e0> (33695.0 17995.0 0.0) ((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (5119.0 -5582.0 0.0)) (<Entity name: 7ffffb16470> <Entity name: 7ffffb164e0> <Entity name: 7ffffb165a0> <Entity name: 7ffffb165c0>))

Command:



Quote
Command: MYBLOCKEDIT

Select object: _.refedit
Select reference: 5 Reference not found.

Select reference:
Select reference: (nentsel)

Select object: (<Entity name: 7ffffb163e0> (33924.0 17992.0 0.0) ((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (5119.0 -5582.0 0.0)) (<Entity name: 7ffffb16470> <Entity name: 7ffffb164e0> <Entity name: 7ffffb165a0> <Entity name: 7ffffb165c0>))
<Bad Entity name: FFB163E0>

ctrlaltdel

  • Guest
Re: LISP to access Block level outside of another block of a clicked entity?
« Reply #14 on: September 04, 2016, 07:38:18 AM »
Hi dan allen.  Any further clues on how to get the lisp to get into "Block in-place"/refedit mode instead of bedit mode?