I have a lsp that breaks a line, and insertes blocks based on a scale variable. In AutoCAD MEP 2011 this lsp routine would put the block onto the same layer as the line it was breaking. In 2014 the block goes onto the current layer. I did a binary compare of the two lsp files and they are indentical. Does anybody know of any variables or changes in AutoCAD core that may cause this behavior?
Thanks,
Dustin
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Maybe I shouldn't chime in, having access to neither any variety of MEP nor any AutoCAD 2011 or 2014 product, but there doesn't appear to be anything at all in that routine that relates to the Layer on which the Block goes, which means it pretty much has to go on the current Layer.
Is the Block defined differently? If it were defined earlier with its pieces on the same Layer as line work into which you would typically put it, and if that would always the same Layer, then it wouldn't matter what the current Layer was at the time -- it would "look like" it was on the same Layer as the linework, even if the insertion itself actually resides on a different Layer. But if it used to be that way, but it's now defined with pieces on Layer 0, then it would always be on whatever the current Layer is at the time, and would "look like" it is.
[It doesn't look like it could be another remote possibility -- a redefined Insert command -- because of Insert being used in a (command) function, which wouldn't accept the command name that way it if it were undefined and a new version defined.]
Kent,
You're right, I also don't see anything in this lisp that would cause layer change. But it's real, I've seen it happening. And no, the block is exactly identical between versions (drawn on Layer 0, co: bylayer). I inherited this code, I didnt write it.
I guess my next step is to find a way to extract and set current the layer of the object selected for breaking. I've been trying to do this, but get errors. Perhaps you could look at what I've done and see if there are any obvious mistakes?
Thank you.
Hi dtiemeyer,
try changing
(setq fp (getpoint "Pick line to break: near to "))
to
(setq sel (entsel "\nPick line to break: near to "));; to get a list with the ename and the picked point
and add
(setq fp (vlax-curve-getClosestPointTo (car sel) (cadr sel) nil));; to get the point on the selected object
or
(setq fp (osnap (cadr sel) "_NEA"))
and change
(setq entlist (entget fp))
to
(setq entlist (entget (car sel)))
HTH
Henrique
Hi Henrique,
First of all, thank you. That does work.
But it changes the second 'click' from a nearest snap to a pickbox element selection. Is there any way to keep it as a nearest snap?
Dustin
I don't understand in your code
where is the function (get_err_vars)
Where is define the variable "insc" and "dwgsc"...
My way;
(defun c:me_ibreak ( / osmode_save abst nam_blk pt_sel ent obj_brk vlaobj deriv alpha) (vl-load-com) (setq osmode_save (getvar "OSMODE")) (setvar "OSMODE" 1536) (setvar "CMDECHO" 0) (if (zerop (getvar "USERR3")) (setvar "USERR3" 100.0)) (initget 2) (setq abst (getdist (strcat"\nEnter gap length <" (rtos (getvar "USERR3") 2 2)">: "))) (if (not abst) (setq abst (getvar "USERR3")) (setvar "USERR3" abst)) (while (not (tblsearch "BLOCK" (setq nam_blk (getstring "\nEnter block name: "))))) (while (setq pt_sel (getpoint"\nPick object to break: near to ")) (setq ent (nentselp pt_sel)) (cond ((and (setq obj_brk (car ent)) (member (cdr (assoc 0 (entget obj_brk))) '("POLYLINE" "LWPOLYLINE" "LINE" "ARC" "CIRCLE" "ELLIPSE" "SPLINE"))) (setq vlaobj (vlax-ename->vla-object obj_brk) deriv (vlax-curve-getFirstDeriv vlaobj (vlax-curve-getParamAtPoint vlaobj (trans pt_sel 1 0))) alpha (atan (cadr deriv) (car deriv)) ) (setvar "OSMODE" 0) (command "_.break" obj_brk (trans (vlax-curve-getPointAtDist vlaobj (- (vlax-curve-getDistAtPoint vlaobj (trans pt_sel 1 0)) (/ abst 2.0) ) ) 0 1) (trans (vlax-curve-getPointAtDist vlaobj (+ (/ abst 2.0) (vlax-curve-getDistAtPoint vlaobj (trans pt_sel 1 0)) ) ) 0 1) ) (command "_.-insert" nam_blk pt_sel (/ abst 8.0) (/ abst 8.0) (angtos alpha)) ) (T (princ "\nThis object can't be break!")) ) (setvar "OSMODE" 1536) ) (setvar "OSMODE" osmode_save) (setvar "CMDECHO" 1) (princ) )
@dtiemeyer wrote:
....
But it changes the second 'click' from a nearest snap to a pickbox element selection. Is there any way to keep it as a nearest snap?
....
You can't apply (entget) to a point [fp], anyway, but it needs an entity name. To get the entity at that point, and apply (entget) to that, you can keep your nearest-osnap and fp variable, and try:
(setq entlist (entget (ssname (ssget fp) 0)))
@dtiemeyer wrote:
Hi Henrique,
First of all, thank you. That does work.
...
You're welcome, Dustin.
@dtiemeyer wrote:
...
But it changes the second 'click' from a nearest snap to a pickbox element selection. Is there any way to keep it as a nearest snap?
...
If you realy need the nearest snap to select the object, you may use the solution already offered by Kent1Cooper, using the ssget function with the fp point.
Henrique
Gentlemen, thank you for your feedback on this, but I'm still having a little trouble making that second 'click' be a nearest snap. I tried inserting that line where I thought it should go, but I'm not getting the results I was expecting.
As the lisp currently stands, there are 2 clicks (nearest snaps) as well as a pickbox selection (at the end) before it loops. Is there any way to eliminate this pickbox snap and just have it be the two nearest snaps?
My apologies if you've already provided me the info to do this, I'm not much of a coder.
@dtiemeyer wrote:
Thanks everybody very much!
You're welcome, Dustin!
My post was marked as "SOLUTION", but I just reviewed your code with the solution offered by Kent1Cooper, so I'll mark is post as "SOLUTION" also.
Henrique