Move anonymous block insertion

Move anonymous block insertion

john.uhden
Mentor Mentor
1,008 Views
14 Replies
Message 1 of 15

Move anonymous block insertion

john.uhden
Mentor
Mentor

I can build an anonymous ("`*U*") block,

and I can entmakex an insertion named 'e' at (setq p0 '(0 0 0))

but when I try to (vl-cmdf "_.move" e "" p0 pause) within the code, AutoCAD crashes.

I can (vl-cmdf "_.move" e "" p0 pause)  after the code (without the move) has finished.

Osmode is 0.

The objects within the block are only lines, text, and one lwpolyline.  No reactors.  No locked layers.

What trick am I missing (gc, regen, vla-update, (setvar "please_behave" 1))?

Should I try using (entlast) instead?

Might my problem be using ACAD2002?

John F. Uhden

0 Likes
Accepted solutions (1)
1,009 Views
14 Replies
Replies (14)
Message 2 of 15

Sea-Haven
Mentor
Mentor

Why insert block/entmake then move why not ask for correct point use that in insert block/entmake ? Not sure what your trying to do.

 

In a pop menu ^c^cINSERT ca3ch-1 DRAG \1;;DRAG

0 Likes
Message 3 of 15

komondormrex
Mentor
Mentor

i am fairly doubtful you can build an anonymous block:

komondormrex_0-1723967202169.png

komondormrex_0-1723967459546.png

asterisk IS USED by the operating system.

thence after a "building" of an anonymous block you've crashed autocad.

imo.

0 Likes
Message 4 of 15

john.uhden
Mentor
Mentor

@komondormrex ,

Entmaking an anonymous block is not a problem.  I've been doing it for decades.

It's the MOVE command that prevents AutoCAD from continuing.

But @Sea-Haven has the answer, I think... Include the positioning with the insertion.

I suppose I could use a (while (not done)(gread ...)) approach to keep changing its insertion point, but I don't think grread obeys any object snaps, the way that MOVE does, not that it should matter, but you must always think about what the user might want.

For you curious lurkers of all levels, one thing I just learned is that once you start entmaking a block definition you must entmake all its parts.  Including a vla-add will make an object, but it won't become part of the block definition.

John F. Uhden

0 Likes
Message 5 of 15

john.uhden
Mentor
Mentor

@Sea-Haven ,

So much for that idea.  Apparently the INSERT (nor -INSERT) command does not accept anonymous block names, even with the "`" prefix, as in "`*U1."   "Invalid block name."

And I certainly don't want to create a named block.

Unless there's another way, grread here we come.

John F. Uhden

0 Likes
Message 6 of 15

Moshe-A
Mentor
Mentor

@john.uhden hi,

 

i do not see any problem (i am on R2022) check mine 😀

 

(defun c:test ()
 (entmake (list '(0 . "BLOCK") '(70 . 1) '(2 . "*Uxxx") '(8 . "0")  '(10 0.0 0.0 0.0)))
 (entmake (list '(0 . "circle") '(8 . "0") '(10 5.0 5.0 0.0) '(40 . 1.0)))
 (setq bname (entmake (list '(0 . "ENDBLK"))))
 (setq ent (entmakex (list '(0 . "INSERT") '(8 . "0") (cons '2 bname) (setq p0 (list 10 0.0 0.0 0.0)) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) '(50 . 0.0))))
 (command "._move" ent "" (cdr p0) pause)
)

 

Message 7 of 15

ec-cad
Collaborator
Collaborator
Accepted solution

Crash may be caused by lack of a Block Definition in the Block Table ?

Once you entmake that block 'insert', try moving entlast..

 

ECCAD

Message 8 of 15

ec-cad
Collaborator
Collaborator

You say: "I can entmakex an insertion named 'e' at (setq p0 '(0 0 0))

but when I try to (vl-cmdf "_.move" e "" p0 pause) within the code, AutoCAD crashes."

 

'e' would be a Blockname ?.. if so, you would need to select it as an entity or object I would

think, in order to "_.move" e ......... if e = a selection set, entity, then fine.

 

ECCAD

 

Message 9 of 15

john.uhden
Mentor
Mentor

@Moshe-A ,

You are always so helpful.

That's great news but, alas, I can test on only ACAD2002. 😖

John F. Uhden

0 Likes
Message 10 of 15

john.uhden
Mentor
Mentor

@ec-cad ,

E is the symbol name for the insert entity.

John F. Uhden

0 Likes
Message 11 of 15

john.uhden
Mentor
Mentor

@ec-cad ,

(entlast) was the trick.  YAY!!

John F. Uhden

0 Likes
Message 12 of 15

Moshe-A
Mentor
Mentor

@john.uhden ,

 

thanks John,

 

The code is for R2002. btw on what platform (OS) you are running 2002?

you did not post your code maybe when insert the block your where using (entmake) instead of (entmakex)?

 

Moshe

 

 

 

 

 

0 Likes
Message 13 of 15

john.uhden
Mentor
Mentor

Hi, @Moshe-A ,

OS is Win10.

I almost always prefer using entmakex because it returns the entity name, as in

(setq e (entmakex ...))

But my AutoCAD could not continue when I tried to "MOVE" e.

I know I had tested (outside the program, leaving e as global) with (entget e) and all looked fine.

Maybe it was a timing issue, but entlast saved the day.  Who woulda thunk? (other than @ec-cad )

John F. Uhden

0 Likes
Message 14 of 15

Moshe-A
Mentor
Mentor

@john.uhden ,

 

It's medical miracle that R2002 works under windows 10, i thought it is crashing on each step?!

 

Moshe

 

 

 

0 Likes
Message 15 of 15

john.uhden
Mentor
Mentor

@Moshe-A ,

It sort of IS a miracle.  I found that I had to use the LongBow installer.  Great people.

John F. Uhden

0 Likes