nmulder Posted April 1, 2011 Share Posted April 1, 2011 Hello all. I am looking for some help/advice with a fairly simple lisp routine I am working on. As the subject says, I want the user to be able to: 1. select an xref 2. select 2nd xref 3. change number "10" dxf code of 2nd xref (insertion point) to match 1st xref I have the routine doing that much but I would like to polish it up to prevent the user from picking non-xref entities or nothing at all. I've played around a little with "while" and "if" statements but I have not yet mastered them. Below is my code with some of my attempts so it isn't nice and neat yet. The routine will be used in our office so the layerstate commands are to address company standard layer usage and issues. Thanks for any help! (defun C:xer (/ 1ent 1elist 1inspnt 2ent 2elist temp) (acet-error-init (list (list "cmdecho" 0 "osmode" (getvar "osmode") "clayer" (getvar "clayer") "attdia" (getvar "attdia") );list T );list );acet-error-init (layerstate-save "temp" 239 nil) (setq 1ent (entsel "\nSelect the source XREF with the desired insertion point: ")) (setq 1elist(entget (car 1ent))) (setq 1inspnt (cdr (assoc 10 1elist))) (setq 1nestent (nentselp (cadr 1ent))) (setq 1nestlist (entget (car 1nestent))) (setq 1nentlay (cdr (assoc 8 1nestlist))) (if (vl-string-search "|" 1nentlay) (alert "yeah!") (alert "Object selected is not an xref. Please try again.")) (setq 2ent (entsel "\nSelect the destination XREF to be moved: ")) (setq 2elist (entget 2ent)) (command ".layer" "unlock" "*" "") (setq 2elist (subst (cons 10 1inspnt)(assoc 10 2elist) 2elist)) (entmod 2elist) (entupd 2ent) (layerstate-restore "temp") (layerstate-delete "temp") (command ".regenall") (setvar "CLAYER" CLay) (setvar "OSMODE" OMode) (setvar "CMDECHO" CEcho) (setvar "ATTDIA" ATTDIAmode) (acet-error-restore) (princ) ) Quote Link to comment Share on other sites More sharing options...
iconeo Posted July 14, 2015 Share Posted July 14, 2015 Try this. Not my code. (defun c:Mxr ( / elst matrix target) (if (and (setq elst (nentselp "\nSelect Source Xref. ")) (setq matrix (caddr elst)) (setq target (car (entsel "\nSelect Target Xref. "))) (setq target (vlax-ename->vla-object target)) ) (progn (vlax-put target 'InsertionPoint '(0.0 0.0 0.0)) (vlax-put target 'XScaleFactor 1.0) (vlax-put target 'YScaleFactor 1.0) (vlax-put target 'ZScaleFactor 1.0) (vlax-put target 'Rotation 0.0) (vla-TransformBy target (vlax-tmatrix matrix)) ) ) (princ) ) (c:mxr) Quote Link to comment Share on other sites More sharing options...
Commandobill Posted July 14, 2015 Share Posted July 14, 2015 A bit more simple: (defun c:xer ( / source matrix target) (if (and (setq source (car (entsel "\nSelect Source Xref. "))) (setq source (vlax-ename->vla-object source)) (setq target (car (entsel "\nSelect Target Xref. "))) (setq target (vlax-ename->vla-object target)) ) (vla-put-insertionpoint target (vla-get-insertionpoint source)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
iconeo Posted July 14, 2015 Share Posted July 14, 2015 This wouldn't cover scale and rotation though correct? Quote Link to comment Share on other sites More sharing options...
Commandobill Posted July 14, 2015 Share Posted July 14, 2015 If you want to check if an object is an xref, you can put another check in there like this: (vlax-property-available-p source 'path) Quote Link to comment Share on other sites More sharing options...
Commandobill Posted July 14, 2015 Share Posted July 14, 2015 This wouldn't cover scale and rotation though correct? No, but the OP didn't ask for rotation or scale, just insertion point. Quote Link to comment Share on other sites More sharing options...
iconeo Posted July 14, 2015 Share Posted July 14, 2015 True, and the OP was from 2011... the dead walk among us. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.