(defun C:incercare (/ )
(setq linie (entget (entlast))
startp (assoc 10 linie) ; line start point
lineen (subst (list 10 5.0 5.0 0.0) startp linie))
(entmod linie)
)
I am trying to modify the starting point of the last line drawed.After calling the incercare function nothing happens
As noted by user CAD Developer, you are calling entmod
on the original DXF data list assigned to the linie
variable, and not the modified list returned by the subst
function and assigned to the lineen
variable.
However, note that your code can be condensed considerably, as each step needn't be assigned to a separate variable, e.g.:
(defun c:incercare ( / linie )
(setq linie (entget (entlast)))
(entmod (subst '(10 5.0 5.0 0.0) (assoc 10 linie) linie))
)
A few points to note here:
Notice that I have declared the symbol linie
as a local variable within the defun
expression, so that the scope of this variable is limited to the c:incercare
function and doesn't remain global.
I have quoted the new coordinate as a literal list using the single quote or apostrophe - this is possible because the list contains only literal data (constant numerical values), and no variable data - I discuss this difference in more detail in my tutorial on The Apostrophe and the Quote Function.
Your current function is assuming that the last entity added to the drawing database is a LINE
entity (or at least, an entity whose geometry is defined by DXF group 10). As such, you may want to include a conditional expression to test whether or not this is the case and branch accordingly, e.g.:
(defun c:incercare ( / ent enx )
(if
(and
(setq ent (entlast))
(setq enx (entget ent))
(= "LINE" (cdr (assoc 0 enx)))
)
(entmod (subst '(10 5.0 5.0 0.0) (assoc 10 enx) enx))
(princ "\nThe last entity was not a line.")
)
(princ)
)