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

different results from ACAD 2011 to ACAD 2014

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
dtiemeyer
444 Views, 12 Replies

different results from ACAD 2011 to ACAD 2014

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

My other CAD is a Cadillac and I like to Revit to the Max!
12 REPLIES 12
Message 2 of 13
Kent1Cooper
in reply to: dtiemeyer

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 Cooper, AIA
Message 3 of 13
dtiemeyer
in reply to: Kent1Cooper

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.

My other CAD is a Cadillac and I like to Revit to the Max!
Message 4 of 13
hmsilva
in reply to: dtiemeyer

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

EESignature

Message 5 of 13
dtiemeyer
in reply to: hmsilva

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

My other CAD is a Cadillac and I like to Revit to the Max!
Message 6 of 13
CADaSchtroumpf
in reply to: dtiemeyer

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)
)

 

Message 7 of 13
Kent1Cooper
in reply to: dtiemeyer


@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)))

Kent Cooper, AIA
Message 8 of 13
hmsilva
in reply to: dtiemeyer


@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

EESignature

Message 9 of 13
dtiemeyer
in reply to: hmsilva

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.

My other CAD is a Cadillac and I like to Revit to the Max!
Message 10 of 13
hmsilva
in reply to: dtiemeyer

Try the attached code.

 

HTH

Henrique

EESignature

Message 11 of 13
dtiemeyer
in reply to: hmsilva

Thanks everybody very much!

My other CAD is a Cadillac and I like to Revit to the Max!
Message 12 of 13
dtiemeyer
in reply to: CADaSchtroumpf

INSC and DWGSC are both variables set in the drawing, by a different lsp.
My other CAD is a Cadillac and I like to Revit to the Max!
Message 13 of 13
hmsilva
in reply to: dtiemeyer


@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

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost