change properties

change properties

Anonymous
Not applicable
1,499 Views
10 Replies
Message 1 of 11

change properties

Anonymous
Not applicable

 

(defun LM:3PArc ( p1 p2 p3 / cn m1 m2 )
(setq m1 (mid p1 p2)
m2 (mid p2 p3)
)
(if
(setq cn
(inters
m1 (polar m1 (+ (angle p1 p2) (/ pi 2.)) 1.0)
m2 (polar m2 (+ (angle p2 p3) (/ pi 2.)) 1.0)
nil
)
)
(append (list cn)
(if (LM:Clockwise-p p1 p2 p3)
(list (angle cn p3) (angle cn p1))
(list (angle cn p1) (angle cn p3))
)
(list (distance cn p1))
)
)
)

 

(defun mid ( a b )
(mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) a b)
)

 

(defun LM:Clockwise-p ( p1 p2 p3 )
(< (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1)))
(* (- (cadr p2) (cadr p1)) (- (car p3) (car p1)))
)
)

 

 

 

(defun c:3PA ( pt1 pt2 pt3)

(setq pt1 (getpoint "\n  Start point: "))

(setq pt2 (getpoint "\n  2nd point: "))

(setq pt2 (getpoint "\n  3rdd point: "))

(if
(and
(setq p1 pt1)
(setq p2 pt2)
(setq p3 pt3)
(setq lst (LM:3PArc (trans p1 1 0) (trans p2 1 0) (trans p3 1 0)))
)
(entmake (append '((0 . "ARC")) (mapcar 'cons '(10 50 51 40) lst)))
)

)

 

 

 

 

 

 

 

how to change the properties of created arc 

color 250

linetype dashed2

 

pls remake the lisp

0 Likes
1,500 Views
10 Replies
Replies (10)
Message 2 of 11

DannyNL
Advisor
Advisor

If you set the current color to 250 and the current linetype to DASHED before running the command, the ARC should get the right properties right away.

 

But if the properties are set in the LISP the ARC will always have the same color and linetype, so why would you want to have that?

 

 

 

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

actually it is a part of program so i want arc always in that properties

0 Likes
Message 4 of 11

DannyNL
Advisor
Advisor

Change the main routine of your code with the code below. There is no error checking on the linetype, so the linetype DASHED2 must be already loaded in your drawing.

 

And please be accurate when you write code yourself as there were more problems with it which caused an error or nothing to happen. It only takes one small mistake to make your code fail and to stop working.

 

(defun c:3PA (/ pt1 pt2 pt3 lst var_list var_values)
   (setq var_values (mapcar 'getvar (setq var_list '("CECOLOR" "CELTYPE"))))
   (mapcar 'setvar var_list '("250" "DASHED2"))
   (setq pt1 (getpoint "\n  Start point: "))
   (setq pt2 (getpoint "\n  2nd point: "))
   (setq pt3 (getpoint "\n  3rd point: "))
   (if
      (and
         pt1
         pt2
         pt3
         (setq lst (LM:3PArc (trans pt1 1 0) (trans pt2 1 0) (trans pt3 1 0)))
      )
      (entmake (append '((0 . "ARC")) (mapcar 'cons '(10 50 51 40) lst)))
   )
   (mapcar 'setvar var_list var_values)
)
0 Likes
Message 5 of 11

Anonymous
Not applicable

it  affected on other elements 

i want to change only the arc element

i have 3 point  is there any another idea to create an arc

0 Likes
Message 6 of 11

DannyNL
Advisor
Advisor

It's not possible that other objects are affected as well.

The color and linetype are changed inside the routine before creating the ARC and changed back to their old values after creating the ARC. As far as I can tell nothing else is created in between, so the settings are only applied to the ARC that is created by the routine.

 

Furthermore I have no idea of what you are trying to achieve by just looking at the code, so if you can post more detailed information and examples of what you want that would definitely help.

0 Likes
Message 7 of 11

joselggalan
Advocate
Advocate

 

Try this..

 

(defun c:3PA ( / pt1 pt2 pt3 lst eArc)
 (if
  (and
   (setq pt1 (getpoint "\n  Start point: "))
   (setq pt2 (getpoint "\n  2nd point: "))
   (setq pt3 (getpoint "\n  3rdd point: "))
   (setq lst (LM:3PArc (trans pt1 1 0) (trans pt2 1 0) (trans pt3 1 0)))
   (setq eArc
	 (entmakex
	  (append
	   '((0 . "ARC"))
	   (mapcar 'cons '(10 50 51 40) lst)
	   '((62 . 250) (6 . "DASHED2"))
	  )
         )
   )
  )
  (redraw eArc 3)
 )
)
(princ)

Note: this will not work if the "DASHED2" line type is not loaded

 

regards.

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

I'm not sure why you don't just use an Arc command with the three points, but however you make the Arc, just add this at the end:

(command "_.chprop" "_last" "" "_color" 250 "_linetype" "DASHED2" "")

 

Unlike other suggestions, this approach does not require that the linetype already be loaded -- it will find it.

Kent Cooper, AIA
Message 9 of 11

joselggalan
Advocate
Advocate

@Kent1Cooper wrote:

 

... 

Unlike other suggestions, this approach does not require that the linetype already be loaded -- it will find it.


Kent,
I am not sure that I find the type of line not loaded, with command.

 

_$ (command "_.chprop" "_last" "" "_color" 250 "_linetype" "DASHED2" "")
; error: Function canceled

Is it my mistake?

0 Likes
Message 10 of 11

Ranjit_Singh
Advisor
Advisor

@joselggalan wrote:

@Kent1Cooper wrote:

 

... 

Unlike other suggestions, this approach does not require that the linetype already be loaded -- it will find it.


Kent,
I am not sure that I find the type of line not loaded, with command.

 

_$ (command "_.chprop" "_last" "" "_color" 250 "_linetype" "DASHED2" "")
; error: Function canceled

Is it my mistake?


I think there is just a typo

(command "_.chprop" "_last" "" "_color" 250 "_ltype" "DASHED2" "")

 

Message 11 of 11

joselggalan
Advocate
Advocate

Ranjit.Singh,
Yes, this does work, or almost ...

 

In Autocad in English:

$ (command "_.chprop" "_last" "" "_color" 250 "_ltype" "DASHED2" "")
nil <- OK.

In autocad in Spanish:

$ (command "_.chprop" "_last" "" "_color" 250 "_ltype" "DASHED2" "")
; error: function canceled


I think the line type files (*. Lin) and the Autocad installation language are also influenced.

0 Likes