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

getting an insertion point of a block

11 REPLIES 11
Reply
Message 1 of 12
enerflex
394 Views, 11 Replies

getting an insertion point of a block

If I have a specific block that is present in a drawing, is there anyway of getting the insertion point data of that block via lisp to use as an insertion point for a different block insertion?
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: enerflex

To select the block and return the insertion point
use this

 

(cdr (assoc 10 (entget (car (entsel "\nSelect
insert: ")))))

 

-Jason


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
If
I have a specific block that is present in a drawing, is there anyway of
getting the insertion point data of that block via lisp to use as an insertion
point for a different block insertion?
Message 3 of 12
enerflex
in reply to: enerflex

Thanks,

Lets say the block is called XXX and I know that and I want to limit the amount of user interaction. I want them to be able to select block XXX or YYY from a list and then let lisp do the rest based on their selection. Is there a way to specify that block name rather than picking it?
Message 4 of 12
Anonymous
in reply to: enerflex

How about this...

 

(defun InsertInsPt ( BlockName )
  (cdr
(assoc 10 (entget (tblobjname "block" BlockName))))
  )

 

;Example:

(InsertInsPt "YourBlockNameHere")

 

-Jason


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks,

Lets say the block is called XXX and I know that and I want to limit the
amount of user interaction. I want them to be able to select block XXX or YYY
from a list and then let lisp do the rest based on their selection. Is there a
way to specify that block name rather than picking
it?

Message 5 of 12
Anonymous
in reply to: enerflex

That will return (0.0 0.0 0.0)

 

(defun InsertInsPt (BlockName)
 (setq
ss (ssget "x" (list (cons 2 BlockName))))

 (if ss

  (cdr (assoc
10 (entget (ssname ss 0))))

  (alert (strcat "No " BlockName  " block
found: "))

 )

)

 

This assumes only one block named BlockName in the
drawing.


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

How about this...

 

(defun InsertInsPt ( BlockName )
  (cdr
(assoc 10 (entget (tblobjname "block" BlockName))))
  )

 

;Example:

(InsertInsPt "YourBlockNameHere")

 

-Jason


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks,

Lets say the block is called XXX and I know that and I want to limit the
amount of user interaction. I want them to be able to select block XXX or
YYY from a list and then let lisp do the rest based on their selection. Is
there a way to specify that block name rather than picking
it?

Message 6 of 12
Anonymous
in reply to: enerflex

oops.  I tested it with a block that the
Insertion point happened to be 0,0.

 

>(defun InsertInsPt (BlockName)

(defun InsertInsPt (BlockName /
ss)

 

-Jason

 

 

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

That will return (0.0 0.0 0.0)

 

(defun InsertInsPt (BlockName)
 (setq
ss (ssget "x" (list (cons 2 BlockName))))

 (if ss

  (cdr (assoc
10 (entget (ssname ss 0))))

  (alert (strcat "No " BlockName  "
block found: "))

 )

)

 

This assumes only one block named BlockName in
the drawing.


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

How about this...

 

(defun InsertInsPt ( BlockName )
  (cdr
(assoc 10 (entget (tblobjname "block" BlockName))))
  )

 

;Example:

(InsertInsPt "YourBlockNameHere")

 

-Jason


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks,

Lets say the block is called XXX and I know that and I want to limit
the amount of user interaction. I want them to be able to select block XXX
or YYY from a list and then let lisp do the rest based on their selection.
Is there a way to specify that block name rather than picking
it?

Message 7 of 12
Anonymous
in reply to: enerflex

This is why I mention including your ACAD release
in my latest post. Hopefull you are running R2000 or above. 

 

Try this..

 

Rotate the current UCS by 90d in Z
axis

Insert a block.

Switch back to the previous UCS.

 

(defun c:prac ()
(alert "This will not return a
point in the WCS")
 (cdr (assoc 10 (entget (car (entsel "\nSelect
Insert: ")))))
)


(defun c:prac2 ()
(alert "This will return a point in the
WCS")
 (vl-load-com)
 (setq obj (vlax-ename->vla-object (car
(entsel "\nSelect Insert: "))))
 (vlax-safearray->list
(vlax-variant-value (vla-get-insertionPoint Obj)))
)

 

Don

 

style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
If
I have a specific block that is present in a drawing, is there anyway of
getting the insertion point data of that block via lisp to use as an insertion
point for a different block insertion?
Message 8 of 12
Anonymous
in reply to: enerflex

After reading your message again, I'm not sure this
is the answer you were looking for. The other guys probably answered
correctly.

 

Don

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

This is why I mention including your ACAD release
in my latest post. Hopefull you are running R2000 or above. 

 

Try this..

 

Rotate the current UCS by 90d in Z
axis

Insert a block.

Switch back to the previous UCS.

 

(defun c:prac ()
(alert "This will not return
a point in the WCS")
 (cdr (assoc 10 (entget (car (entsel "\nSelect
Insert: ")))))
)


(defun c:prac2 ()
(alert "This will return a point in the
WCS")
 (vl-load-com)
 (setq obj (vlax-ename->vla-object
(car (entsel "\nSelect Insert: "))))
 (vlax-safearray->list
(vlax-variant-value (vla-get-insertionPoint Obj)))
)

 

Don

 

style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
If
I have a specific block that is present in a drawing, is there anyway of
getting the insertion point data of that block via lisp to use as an
insertion point for a different block
insertion?
Message 9 of 12
enerflex
in reply to: enerflex

Thanks Jim,

Is the 'x' supposed to be a certain value .... I get a too few arguments error when I try to run it

here's the code I used:

(defun c:InsertInsPt (phil)
(setq ss (ssget "x" (list (cons 2 phil))))
(if ss
(cdr (assoc 10 (entget (ssname ss 0))))
(alert (strcat "No " phil " block found: "))
)
)

'phil' is the name of the block that is defined.
Message 10 of 12
Anonymous
in reply to: enerflex

Change the (defun c:InsertInsPt (phil) to (defun
InsertInsPt (phil / ss)

 

The to use the command to find the insert point of
a block named widget

    (insertinspt
"widget")


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
Jim,

Is the 'x' supposed to be a certain value .... I get a too few arguments
error when I try to run it

here's the code I used:

(defun c:InsertInsPt (phil)
 (setq ss (ssget "x" (list (cons 2
phil))))
 (if ss
  (cdr (assoc 10 (entget (ssname ss
0))))
  (alert (strcat "No " phil " block found: "))
 )

)

'phil' is the name of the block that is
defined.

Message 11 of 12
enerflex
in reply to: enerflex

(defun InsertInsPt (phil / ss)
(setq ss (ssget "x" (list (cons 2 phil))))
(if ss
(cdr (assoc 10 (entget (ssname ss 0))))
(alert (strcat "No " phil " block found: "))
)
)

I thought this might be a little easier way of corresponding ... I hope you don't mind.
I'm a little rusty on the lisp end of things but I basically understand what is going on here.
The block name is 'phil' and the insertion point is 2,2,0.
ssget "x" will return all the objects in the drawing.
I'm not real clear on what cons does.

when I attempt to run this, I get a bad SSGET list value.

any help that you might be able to provide would be greatly appreciated
Message 12 of 12
Anonymous
in reply to: enerflex

If you see my post, the point returned by DXF 10
may have to be translated to the current UCS to be accurate.

 

Don

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
(defun
InsertInsPt (phil / ss)
 (setq ss (ssget "x" (list (cons 2 phil))))

 (if ss
  (cdr (assoc 10 (entget (ssname ss 0))))

  (alert (strcat "No " phil " block found: "))
 )
)

I thought this might be a little easier way of corresponding ... I hope you
don't mind.
I'm a little rusty on the lisp end of things but I basically
understand what is going on here.
The block name is 'phil' and the
insertion point is 2,2,0.
ssget "x" will return all the objects in the
drawing.
I'm not real clear on what cons does.

when I attempt to run this, I get a bad SSGET list value.

any help that you might be able to provide would be greatly
appreciated

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

Post to forums  

Autodesk Design & Make Report

”Boost