View Full Version : STLPlus Add-on - Snap to Insertion point of a Block inside an Xref
bgarrett
2005-06-17, 03:36 PM
At my place of employment we run an add-on to cad called STLPlus. It allows you to put in structural member sizes as a block and it has an insertion point in the center of the block. The drawing is then xref-ed into other drawings for the framing and foundation. I would like to be able to snap to the insertion point of the structural column which is located in the xref. Is there some way to snap to that point currently? If so, need some help to do so. I do not know to much about the insertion command so any help would be greatly appreciated. I was refered to this forum by another member that thought you guy might be able to help.
bbapties
2005-06-17, 03:44 PM
This isnt a lisp answer but I ran into this before and I ended up going thru all my blocks and inserting a node on defpoints at the insertion point......Now I just use the node osnap....
CAB2k
2005-06-17, 09:38 PM
The node idea is a good one.
It is not clear to me what your are snapping.
Are you drawing a line, lets say and you want to snap it to the insert point of this block?
In that case, quote :Insert Snaps to the insertion point of text, a block, a shape, or an attribute: INS
When you are ready to snap the line to the insert just type INS as the command line
during the LINE command,
Perhaps I'm off track here.
bbapties
2005-06-17, 09:59 PM
I think what he is trying to do is snap to the insertion point of a block that is within an xref.....
If you try to snap to the "ins" of said block that is inside an xref, it will snap to the insertion point of the xref...(usually 0,0,0)
CAB2k
2005-06-17, 10:27 PM
OK neighbor, thanks for the clarification, I see the problem now.
/scratching head
peter
2005-06-18, 04:37 PM
This is a job for the nentsel command.
If you type (nentsel) at the command line and select the bloack inside the xref you get something like this.
(<Entity name: 7a7e9980> (58426.4 58254.9 0.0) ((1.0 0.0 0.0)
(0.0 1.0 0.0) (0.0 0.0 1.0) (58421.6 58248.2 0.0)) (<Entity name: 7a7f88d8>
<Entity name: 7a5fb180>))
The last item in this list includes two entity names, and I just found that the first one is the block you want the insertion point from. So if in the middle of your command you want to get the insertion of this block (wshape) you first need to load this routine and then type 'cins for column insertion points and select any part of the block and it will grab the insertion point.
Peter Jamtgaard
(defun C:CINS ()
(car (reverse (caddr (nentsel))))
)
kennet.sjoberg
2005-06-18, 05:02 PM
There is a solution, easy if everything is created in WCS, but really sticky if not.
I tested to make a getdata function (ins) to use as _endp, _cen, _per, _mid . . .
With the nentsel I can get the coordinates of the main and the sub block and calculate
the coordinates to the actual space, that in no problem and the program works great,
but the problem is to calculate the point when using different UCS,
I can not find the relation between WCS, UCS, angles and insertion points ....yet.
Use like : Command: ._LINE Specify first point: (ins) pick complex block object :
;;; There you usually use _endp, _cen, _per or _mid USE (ins)
;;; Example
;;; Command: ._line Specify first point: (ins) pick complex block object :
(defun ins (/ Ent World Co1 Co2 Pkt )
(if (setq Ent (nentsel "pick complex block object : " ))
(progn
(if (and (equal (getvar "UCSXDIR" ) (list 1.0 0.0 0.0)) (equal (getvar "UCSYDIR" ) (list 0.0 1.0 0.0)) )
(setq World T )
(setq World nil )
)
(cond
((= (length Ent ) 2 )
(princ " simple object, used regular snap point ")
)
((= (length (car (reverse Ent ))) 1 ) ;; complex object main
(setq Co1 (assoc 10 (entget (caar (reverse Ent )))) ) ; main WCS
(setq Pkt (list (cadr Co1 ) (caddr Co1 )) )
(if World (trans Pkt 0 0 ) (trans Pkt 0 1 ) )
)
((= (length (car (reverse Ent ))) 2 ) ;; complex object sub
(setq Co1 (assoc 10 (entget (cadr (car (reverse Ent ))))) ) ; main WCS
(setq Co2 (assoc 10 (entget (car (car (reverse Ent ))))) ) ; sub WCS
(if World
(setq Pkt (list (+ (cadr Co1 )(cadr Co2 )) (+ (caddr Co1 )(caddr Co2 ))) )
(progn
(setq Co1 (trans (list (cadr Co1 )(caddr Co1 )) 0 1 ) ) ; main UCS
(setq Co2 Co2 ) ; sub UCS
;;; v--- I am lost here, I can not figured out how to calculation the Pkt here
(setq Pkt (list (+ (car Co1 )(car Co2 )) (+ (cadr Co1 )(cadr Co2 ))) ) <-- WRONG
)
)
)
(t nil) ; Happy Computing ! kennet
)
)
(princ " Miss, aim better ! " )
)
)
: ) Happy Computing !
Please try to help me
kennet
kennet.sjoberg
2005-06-19, 12:30 PM
hmm.. yesterday I was lost, not today. Here is probably a working code
;;; There you usually use _endp, _cen, _per or _mid USE (ins)
;;; Example
;;; Command: ._line Specify first point: (ins) pick complex block object :
(defun ins (/ Ent World Co1 Co2 Pkt )
(if (setq Ent (nentsel "pick complex block object : " ))
(progn
(if (and (equal (getvar "UCSXDIR" ) (list 1.0 0.0 0.0)) (equal (getvar "UCSYDIR" ) (list 0.0 1.0 0.0)) )
(setq World T )
(setq World nil )
)
(cond
((= (length Ent ) 2 )
(princ " simple object, use regular snap point ")
)
((= (length (car (reverse Ent ))) 1 )
(setq Co1 (assoc 10 (entget (caar (reverse Ent )))) )
(setq Pkt (list (cadr Co1 ) (caddr Co1 )) )
(if World (trans Pkt 0 0 ) (trans Pkt 0 1 ) )
)
((= (length (car (reverse Ent ))) 2 )
(setq Co1 (assoc 10 (entget (cadr (car (reverse Ent ))))) )
(setq Co2 (assoc 10 (entget (car (car (reverse Ent ))))) )
(if World
(setq Pkt (list (+ (cadr Co1 )(cadr Co2 )) (+ (caddr Co1 )(caddr Co2 ))) )
(progn
(setq Pkt (list (+ (cadr Co1 )(cadr Co2 )) (+ (caddr Co1 )(caddr Co2 ))) )
(setq Pkt (trans pkt 0 1 ) )
)
)
)
(t nil) ; Happy Computing ! kennet
)
)
(princ " Miss, aim better ! " )
)
)
; ) Happy Computing !
kennet
bgarrett
2005-06-20, 02:59 AM
Thanks for all of the help. I will try some of your suggestions Monday. Thanks again.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.