Author Topic: Getting insertion point of block INSIDE another block.  (Read 10330 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Getting insertion point of block INSIDE another block.
« on: January 07, 2007, 07:57:26 PM »
Hi all,..

We have many block inside block inside block..

But i need to get insertion point of specific block...

there is my code.
Code: [Select]
(setq ins (cdr (assoc 10 (tblsearch "BLOCK" "HQZP1"))))
If the block itself is not present in current drawing...
the (ssget.... command can't see to find it.

any suggestion ?
« Last Edit: January 07, 2007, 07:58:50 PM by Andrea »
Keep smile...

M-dub

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #1 on: January 07, 2007, 08:52:53 PM »
I don't really understand the question either... :?

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #2 on: January 08, 2007, 02:42:20 AM »
If i understand, with this ?

Code: [Select]
(setq ins (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) "HQZP1"))
(vlax-get ins 'origin)

@+

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #3 on: January 08, 2007, 04:36:08 AM »
Ah yes, it's exact i'm not awaked yet this morning  ;-)
According to which I understand, Andrea seeks the block of insertion of a block include in another

@+

Joe Burke

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #4 on: January 08, 2007, 05:19:28 AM »
Here's something by Luis which should help, if I understand the question.

I saved it because it's interesting how he does it. Hi Luis.  :-)

;; -------------------------------
;; by Luis posted 10/31/2005
(defun draw_point  (pt col / d)
  (setq d (* (getvar "viewsize") 0.015))
  (grdraw
    (trans (polar pt (* 0.25 pi) d) 0 1)
    (trans (polar pt (* 1.25 pi) d) 0 1)
    col
    (- col))
  (grdraw
    (trans (polar pt (* 0.75 pi) d) 0 1)
    (trans (polar pt (* 1.75 pi) d) 0 1)
    col
    (- col)))

;; get nested block insertion point
(defun C:NESTIP  (/ ndata)
  (if (and (setq ndata (nentsel)) (> (length ndata) 2))
    (draw_point (last (caddr ndata)) 7))
  (princ))
;; -------------------------------

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #5 on: January 08, 2007, 07:16:17 AM »
Great,
but your lisp work only for one level of nested block

@+

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #6 on: January 08, 2007, 07:25:05 AM »
Oh, it's not necessary to be sorry. Me the first i'm far from thinking of all.  8-)
But you are right, wait to have an answer to our questions.

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Getting insertion point of block INSIDE another block.
« Reply #7 on: January 08, 2007, 09:38:11 AM »
....
there is my code.
Code: [Select]
(setq ins (cdr (assoc 10 (tblsearch "BLOCK" "HQZP1"))))....
Andrea, please explain exactly what you think this code does.

this should be retreive dxf code of insertion block point.
but it always 0,0,0.....i don't understand why.
Keep smile...

Joe Burke

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #8 on: January 08, 2007, 09:47:47 AM »
It's always 0,0,0 because you are looking at the block definition, rather than a block reference/insert.

Try the code I posted by Luis.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Getting insertion point of block INSIDE another block.
« Reply #9 on: January 08, 2007, 11:03:14 AM »
Hola Joe,

Glad you are here Sir!


Andrea;

In Italian:
Trasmettere la vostra domanda sulla vostra propria lingua.

In French
Transmettre votre question dans votre propre langue.





LE....thanks.

French:
J'essai d'obtenir le point d'insertion d'un block contenu dans un block.
cependant, je n'arrive pas à savoir comment y parvenir car l'orsque j'extrait les données
des entitées les code DXF me reviens toujour à 0,0,0 et je ne comprend pas le pourquoi.

Italian:
il mio francese è un po migliore che mia lingua natale.
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Getting insertion point of block INSIDE another block.
« Reply #10 on: January 08, 2007, 11:33:53 AM »
Go here and test the routine, it does what you want.

http://www.theswamp.org/index.php?topic=14347.msg172782#msg172782


Have fun.

lol....

Thanks LE...I saw the Joe routine..and I put on my example list.  thanks Joe.

but, (nentsel ...allow user to select the block....and than capture the nested entity..
but I need to know how to select this block without user intervention.
to extract entity data.
Keep smile...

Tramber

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #11 on: January 08, 2007, 11:55:31 AM »
See there.

Hope you are a member ! (it is necessary if you want to see some answers (they are brilliant)).



En +, c'est en Français, dingue non ?

http://www.hyperpics.com/customization/autolisp/
At hyperpics, it used to be a great routine called return-nested but they've just changed the website and I can't find it any more. Too bad 'cause it was just for you.

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #12 on: January 08, 2007, 12:31:13 PM »
With this ?

Code: [Select]
(defun c:rin(/ bls pt ins)
  (defun pts (bl)
    (vlax-for ent bl
      (if (eq (vla-get-ObjectName ent) "AcDbBlockReference")
        (progn
          (princ (strcat "\nSous bloc --> " (vla-get-name ent) " --> Point d'insertion --> "))
          (princ (mapcar '+ (trans pt 1 0) (vlax-get ent 'InsertionPoint)))
          (pts (vla-item bls (vla-get-name ent)))
        )
      )
    )
  )

  (setq sel (entget (car (entsel))) bls (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
  (princ (strcat "\nBloc maitre --> " (cdr (assoc 2 sel))" --> Point d'insertion --> "))
  (princ (trans (setq pt (cdr (assoc 10 sel))) 1 0))
  (pts (vla-item bls (cdr (assoc 2 sel))))
  (princ)
)

You can update the lisp and do a vlax-for in the blocks table

@+

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Getting insertion point of block INSIDE another block.
« Reply #13 on: January 08, 2007, 06:35:09 PM »
Thanks...interesting..

but in fact, I think is not easier that we think..

We have block Y in Block X

So I think like this...

1) found the babyBlock Y
2) retreive the name of the motherBlock X
3) extract all information of the motherBlock X to retreive the coordinate of the BabyBlock Y

This fonction do not required any selection....just filter.

Is this what I need to do ? can be done like that ?
Keep smile...

Patrick_35

  • Guest
Re: Getting insertion point of block INSIDE another block.
« Reply #14 on: January 09, 2007, 02:49:27 AM »
Quote
This will not work on a scaled, rotated, mirrored, uniform block

You tested it?. it's work with any block insert on drawing (scaled, rotated, mirrored, uniform block)

@+