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

finding insert point...

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
608 Views, 13 Replies

finding insert point...

does this syntax only work for block insert points?
(setq ins (ssget "X" (list (cons 0 "INSERT"))))

or can this work if you do a copy / paste from clip board?
if so whats the right way to get this to work from the clipboard?
what im trying to do is find the insert point of an object that is pasted from the clipboard
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

[That will also find Xrefs.]

If you use PASTEBLOCK, rather than PASTECLIP or PASTEORIG, the pasted
content will be an Inserted object, and will have an insertion point and be
found by that (ssget) language. Otherwise, it will find any Block(s) that
may be part of what was pasted, but you would only be able to get the
resultant insertion point(s) of the Block(s), not the point used to paste
it/them into the drawing.
--
Kent Cooper


wrote...
does this syntax only work for block insert points?
(setq ins (ssget "X" (list (cons 0 "INSERT"))))

or can this work if you do a copy / paste from clip board?
if so whats the right way to get this to work from the clipboard?
what im trying to do is find the insert point of an object that is pasted
from the clipboard
Message 3 of 14
Anonymous
in reply to: Anonymous

Hi,

The expression (cons 0 "INSERT") has nothing to do with whatever point or
whatsoever. DXF code 0 is associated to Entity Type information for all
entities in AutoCAD, so its associated value is not about any point, but
about what entity type it belongs to. In this case it's about an 'insert' of
a block definition. This is known also under the name of 'block reference',
or an instance of that block definition. This won't work for anything else
than inserted blocks.

If you want to get the insertion point of the last inserted object, you have
to use (entlast), check what kind of entity was inserted and then retrieve
the appropriate DXF code (or the appropriate property if you use ActiveX
stuff) for the insertion point.

HTH,

Constantin


a écrit dans le message de news:
5519342@discussion.autodesk.com...
does this syntax only work for block insert points?
(setq ins (ssget "X" (list (cons 0 "INSERT"))))

or can this work if you do a copy / paste from clip board?
if so whats the right way to get this to work from the clipboard?
what im trying to do is find the insert point of an object that is pasted
from the clipboard
Message 4 of 14
Anonymous
in reply to: Anonymous

so instead of the (cons 0 "insert") i need to use entlast
is that what you are suggesting?
Message 5 of 14
Anonymous
in reply to: Anonymous

Hi Andrew,

First of all (entlast) is not something meant to be used 'instead' (cons 0
"INSERT"). The first one is a function in itself which will return the name
of the last nondeleted main object (entity) in the drawing, while (cons 0
"INSERT") is a criteria being used to filter when using (ssget ...) in order
to make sure that the selected entities are of the 'insert' type (which is
the same as a block reference, which is the same as an instance of a block
definition).

So what I suggest, is that after you insert your thing (which I assume it
can be a text string, an image or what ever other entity from another
drawing), from the clipboard, use (entlast), then analyze what (entget
(entlast)) returns. The DXF code 0 will tell you what is the last object:

(0 . "INSERT") -> it's a block reference or an xref
(0 . "IMAGE") -> it's an image
(0 . "TEXT") -> it's text
(0 . "MTEXT") -> it's mtext
(0 . .LINE") -> it's a line
(0 . "CIRCLE") -> it's a circle
(0 . "ACAD_TABLE") -> it's a table
(0 . "TOLERANCE") -> it's a tolerance
(0 . "WIPEOUT") -> it's a wipeout
(0 . "SHAPE") -> it's a shape

and so on, or if you know exactly what object was inserted, you can skip
this step. When you know what the entity is, you can check for the insertion
point of that entity. Remember that only blocks, xrefs (which are special
blocks), mtext, images, tables, tolerances, wipeouts and shapes (hope I
didn't forget something) have insertion points (it's a good thing to read
about DXF codes grouped by entity type in order to see what goes with what).
For all these, the insertion point is associated to code DXF 10 (also might
be 20 and 30 for the tables).

HTH,

Constantin



a écrit dans le message de news:
5519854@discussion.autodesk.com...
so instead of the (cons 0 "insert") i need to use entlast
is that what you are suggesting?
Message 6 of 14
Anonymous
in reply to: Anonymous

[Text (of the non-M variety) also has an insertion point.]

One question I would ask of Andrew is what is meant in the original post by
wanting to "find the insert point of an object that is pasted from the
clipboard." If that means to find the object's own internal insertion point
(assuming it has one), then Constantin's advice is fine. But I would assume
that's *not* what is meant, because that doesn't need to be related to
copying and pasting at all -- how the object got into the drawing is
irrelevant.

If, on the other hand, that phrase means you want to find *the point that
was picked* in the target drawing during the pasting operation, then I
believe you're out of luck, unless:
a) You used the PasteBlock variety of pasting, in which case the
wacky-named block that results will have that as its insertion point, or;
b) You used the CopyBase variety of copying to get it from the source
drawing, *and* the object is something that has its own insertion point,
*and* that was the point selected as the base point in CopyBase, or;
c) You used mere CopyClip to get it and PasteClip to bring it in, *and* it
has an insertion point, *and* that happens to be at the lower left corner of
its extents, which is what CopyClip/PasteClip will use.

But choices b) and c) above are only coincidental -- they find the point
you're looking for only because it happens to coincide with the insertion
point of the object.

And if you pasted in *more than one* object, and want the point at which
they were pasted, then PasteBlock is probably your only hope.

--
Kent Cooper


"Constantin" wrote...
Hi Andrew,

.... Remember that only blocks, xrefs (which are special
blocks), mtext, images, tables, tolerances, wipeouts and shapes (hope I
didn't forget something) have insertion points ....
Message 7 of 14
Anonymous
in reply to: Anonymous

the point that was picked when using pastclip is exactly what im after.
since that isnt feasible, i guess i will have to use the pasteblock as you suggested and go from there.
Message 8 of 14
Anonymous
in reply to: Anonymous

Hi Kent,

There is no DXF code for text that says 'Insertion point' as for Mtext.DXF
code 10 for text it's called 'First alignment point'. From the help:

TEXT:

Group code 10
First alignment point (in OCS)
DXF: X value; APP: 3D point

Constantin

"Kent Cooper" a écrit dans le message de
news: 5520010@discussion.autodesk.com...
[Text (of the non-M variety) also has an insertion point.]

One question I would ask of Andrew is what is meant in the original post by
wanting to "find the insert point of an object that is pasted from the
clipboard." If that means to find the object's own internal insertion point
(assuming it has one), then Constantin's advice is fine. But I would assume
that's *not* what is meant, because that doesn't need to be related to
copying and pasting at all -- how the object got into the drawing is
irrelevant.

If, on the other hand, that phrase means you want to find *the point that
was picked* in the target drawing during the pasting operation, then I
believe you're out of luck, unless:
a) You used the PasteBlock variety of pasting, in which case the
wacky-named block that results will have that as its insertion point, or;
b) You used the CopyBase variety of copying to get it from the source
drawing, *and* the object is something that has its own insertion point,
*and* that was the point selected as the base point in CopyBase, or;
c) You used mere CopyClip to get it and PasteClip to bring it in, *and* it
has an insertion point, *and* that happens to be at the lower left corner of
its extents, which is what CopyClip/PasteClip will use.

But choices b) and c) above are only coincidental -- they find the point
you're looking for only because it happens to coincide with the insertion
point of the object.

And if you pasted in *more than one* object, and want the point at which
they were pasted, then PasteBlock is probably your only hope.

--
Kent Cooper


"Constantin" wrote...
Hi Andrew,

.... Remember that only blocks, xrefs (which are special
blocks), mtext, images, tables, tolerances, wipeouts and shapes (hope I
didn't forget something) have insertion points ....
Message 9 of 14
Anonymous
in reply to: Anonymous

The point that was picked when using pasteclip is given by the expresion.

(getvar 'lastpoint)

You see, it's allways important to ask the right question. This could have
saved a lot of time to all involved in this thread.


Constantin


a écrit dans le message de news:
5520197@discussion.autodesk.com...
the point that was picked when using pastclip is exactly what im after.
since that isnt feasible, i guess i will have to use the pasteblock as you
suggested and go from there.
Message 10 of 14
Anonymous
in reply to: Anonymous

Perhaps a matter of semantics -- I was thinking in terms of what Osnap
Insert will snap to, which would seem to qualify as an Insertion point for
any practical purpose.
--
Kent Cooper


"Constantin" wrote...
Hi Kent,

There is no DXF code for text that says 'Insertion point' as for Mtext.DXF
code 10 for text it's called 'First alignment point'. From the help:

TEXT:

Group code 10
First alignment point (in OCS)
DXF: X value; APP: 3D point

Constantin
....
Message 11 of 14
Anonymous
in reply to: Anonymous

[That's assuming you want to find that point immediately after pasting, with
nothing else since that would change the Lastpoint variable. If that's the
OP's situation, this is obviously the easy solution.]
--
Kent Cooper


"Constantin" wrote...
The point that was picked when using pasteclip is given by the expresion.

(getvar 'lastpoint)

....
Message 12 of 14
Anonymous
in reply to: Anonymous

Yes, I was thinking the same, but it seems that there is a slight and subtle
nuance for Autodesk.

Constantin

"Kent Cooper" a écrit dans le message de
news: 5520790@discussion.autodesk.com...
Perhaps a matter of semantics -- I was thinking in terms of what Osnap
Insert will snap to, which would seem to qualify as an Insertion point for
any practical purpose.
--
Kent Cooper


"Constantin" wrote...
Hi Kent,

There is no DXF code for text that says 'Insertion point' as for Mtext.DXF
code 10 for text it's called 'First alignment point'. From the help:

TEXT:

Group code 10
First alignment point (in OCS)
DXF: X value; APP: 3D point

Constantin
....
Message 13 of 14
Anonymous
in reply to: Anonymous

Andrew,

Is your question here related to the other topic, "automatic scaling"? If so using
PasteBlock sounds like a good idea.

Joe Burke

wrote in message news:5520197@discussion.autodesk.com...
the point that was picked when using pastclip is exactly what im after.
since that isnt feasible, i guess i will have to use the pasteblock as you suggested
and go from there.
Message 14 of 14
Anonymous
in reply to: Anonymous

Joe,
Yes this had to do with the other post "automatic scaling"
plus i used this for other block inserting lisp files i have

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

Post to forums  

Autodesk Design & Make Report

”Boost