Need LISP to automatically put arrow arc text

Need LISP to automatically put arrow arc text

Anonymous
Not applicable
6,492 Views
30 Replies
Message 1 of 31

Need LISP to automatically put arrow arc text

Anonymous
Not applicable

I need a lisp in which i can use a single command to add an arc with arrow and text. For more clarification steps are mentioned below:

after entering command

1-select point for arrow ( i want to use my own arrow block )

2-select rotation for arrow

3-arc ( first point of arc will be the point we selected in step 1, 2nd & 3rd points we can select manually- i want to use my similar properties for arc named with "Ref. Line"  )

4- add text ( not mtext, also i want to use my similar properties for text named with "Ref. No." )

5-edit that text

6-move text

is there anyone who can help me in this?

i can't able to prepare LISP commands but i need this one. Please help me.arrow arc text.PNG

0 Likes
Accepted solutions (2)
6,493 Views
30 Replies
Replies (30)
Message 21 of 31

dlanorh
Advisor
Advisor

Try the attached. The layers must already exist in the drawing

I am not one of the robots you're looking for

0 Likes
Message 22 of 31

Anonymous
Not applicable

While using arrows with text at different rotations i am facing a issue which is shown in below image.

arrow txt.PNG

i need these arrows something like below image.

 

arrow txt needed.PNG

everything is perfect except this. Please resolve this issue. Thank you so much for giving me your precious time & helping me in this.

0 Likes
Message 23 of 31

dlanorh
Advisor
Advisor

I cannot resolve an issue i cannot reproduce. How are you producing the top image?  Please attach the drawing that produced these so i can compare it with mine.

 

If you are rotating the arcs and arrows after inserting them then i cannot fix it as they are three seperate objects and not a multileader.

The object of the lisp is you construct the arc you want and the lisp puts the text and arrow in the correct place.

I am not one of the robots you're looking for

0 Likes
Message 24 of 31

dlanorh
Advisor
Advisor

In light of the problems with the spline and text lisp, are you perhaps changing the text style of the text after the lisp has run?

 

If you are, please type mleaderstyle on the command line, select the arc style and press modify. Go to the content tab and ensure that Text Style is set to "Ref. No." by clicking on the little down arrow and selecting it from the list. Then press OK and then Close the dialog.

 

Then retry the lisp. I still cannot reproduce what is happening in the upper image.

I am not one of the robots you're looking for

0 Likes
Message 25 of 31

Anonymous
Not applicable

As you see in 1st image i just enter the command and draw arrows in different directions, arrows are fine but text is not aligned with the arrow line.

 I want to draw the arrow with text as shown in 2nd image.

To do this i need to modify the text style first from mleaderstyle & then enter the command. i need this in the same way you did in "sptxt" ( if i prepare a spline at any angle, text will automatically come at correct place ). I don't want to edit or modify the arrow. I want to fix arrow, arc and text properties.

 

For example, In sptxt we used spline, now here we replace the spline with arrow & arc, text will remain same.

 

0 Likes
Message 26 of 31

dlanorh
Advisor
Advisor
I understand that, and I can implement the text as in "sptxt", but there is something different in your drawing to my drawing that is causing the text to displace. I cannot reproduce the problem you are having. When I use the lisp it doesn't happen.

Perhaps once the "sptxt" function is implemented it will go away.

I am not one of the robots you're looking for

0 Likes
Message 27 of 31

dlanorh
Advisor
Advisor
Accepted solution

OK. Attached is a new Lisp based on "sptxt" You will still need the "newarrow" block but you can erase the "Arc" Multileader style as the lisp no longer needs or works with it.

 

Near the top of the lisp file are the following lines. If you need to change the arrow size open the lisp file in a text editor and change the red 2.0 to the scale factor required. Changing it to 4.0 will double the size of the arrow. etc. Then save the file, before loading it again to update the changes.

 

;; Adjustable variables follow
	(setq b_scale 2.0)          ;This is the block scale (arrow scale)
  

When you have loaded the lisp type "artxt" on the command line to run it.

 

If this still displaces text then there is a problem with your autocad setup.

 

I am not one of the robots you're looking for

0 Likes
Message 28 of 31

Anonymous
Not applicable

Its working. Great

Thanks Dlanorh

0 Likes
Message 29 of 31

dbhunia
Advisor
Advisor

Please go through the modified code........


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 30 of 31

dbhunia
Advisor
Advisor

please go through the modified code 

 

 


@Anonymous wrote:

can you please modify below points in it:

1) I want to put arrow, arc & text in different layers ( "solid" for arrow, " Ref. line" for arc & "Ref. No." for text ).

2) I want to place text manually.

Thanks in advance.


(vl-load-com)
;; Changes ML into arc with arrowhead + text
;;
;; To change the arrow size or text size, type "mleaderstyle" on the command line
;; This will bring up the multiLeader style manager
;; Select the "Arc" Style from the list on the left side and press the "Modify" Button
;; On the next pop up, the arrowhead size can be changed on the "Leader Format" Tab;
;; and the text size on the "Content" Tab
;;
;; written by : Ron Harman (2015)
;; V2 updated some algorithms to VLisp (2017)
;;
;; Type ml2arc to run
;;
(defun c:ml2arc ( / *error* c_doc ms c_mls cmls mls_lst ml_txt pt1 a_obj e_pt s_pt pt2 pt3 ml_ent ml_obj c_obj minExt maxExt ss)

(defun *error* ( msg )
(if cmls (setvar 'cmleaderstyle cmls))
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error occurred : " msg)))
(princ)
);end_defun *error*

(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
ms (vla-get-modelspace c_doc)
c_mls (vla-item (vla-get-dictionaries c_doc) "ACAD_MLEADERSTYLE")
);end_setq

;construct list of MLeader style names present in drawing
(vlax-for itm c_mls (setq mls_lst (cons (vlax-get itm 'name) mls_lst)))

;If MLStyle "Arc" not in drawing Alert and exit
(cond ( (not (member "Arc" mls_lst))
(alert "MLeader Style \"Arc\" NOT present in drawing. Exiting..")
(exit)
)
);end-cond

;If MLStyle "Arc" not current Style -> Save current Style and set "Arc" current
(cond ( (/= "Arc" (getvar 'cmleaderstyle))
(setq cmls (getvar 'cmleaderstyle))
(setvar 'cmleaderstyle "Arc")
)
);end_cond

(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(vla-startundomark c_doc)

(setq ml_txt (getstring T "\nEnter Leader Text : ")
pt1 (getpoint "\nSelect Arrowhead point for Arc : ")
);end_setq
(command "_Arc" pt1 pause pause)
(setq ml_ent_arc (entlast))
(command "_.chprop" ml_ent_arc "" "LA" "Ref. line" "")
(setq a_obj (vlax-ename->vla-object (entlast))
e_pt (vlax-curve-getendpoint a_obj)
s_pt (vlax-curve-getstartpoint a_obj)
pt2 (vlax-curve-getpointatdist a_obj (/ (vlax-get-property a_obj 'arclength) 2))
);end_setq
(if (equal pt1 e_pt 0.001) (setq pt3 s_pt) (setq pt3 e_pt))
(command "_mleader" pt1 pt2 pt3 ml_txt)
(setq ml_ent (entlast)
ml_obj (vlax-ename->vla-object ml_ent)
c_obj (vla-addcircle ms (vlax-3d-point pt1) (vlax-get-property ml_obj 'arrowheadsize))
i_pt (vlax-invoke a_obj 'intersectwith c_obj acExtendNone)
r_ang (angle i_pt pt1)
);end_setq
(vla-delete c_obj)
(vla-getboundingbox ml_obj 'minExt 'maxExt)
(setq minExt (reverse (cdr (reverse (vlax-safearray->list minExt))))
maxExt (reverse (cdr (reverse (vlax-safearray->list maxExt))))
);end_setq
(command "_explode" ml_ent)
(setq ss (ssget "_W" minExt maxExt (list '(0 . "INSERT,MTEXT,*LINE"))))
(vlax-for obj (vla-get-activeselectionset c_doc)
(cond ( (wcmatch (vlax-get-property obj 'objectname) "*MText")
(command "_.chprop" (vlax-vla-object->ename obj) "" "LA" "Ref. No." "")
(command "move" (vlax-vla-object->ename obj) "" (cdr (assoc 10 (entget (vlax-vla-object->ename obj)))))
(command "_explode" (vlax-vla-object->ename obj))
)
( (wcmatch (vlax-get-property obj 'objectname) "*BlockReference")
(command "_.chprop" (vlax-vla-object->ename obj) "" "LA" "solid" "")
(vlax-put-property obj 'rotation r_ang)
)
(t
(vla-delete obj)
)
);end_cond
);end_for
(setq ss nil)
(if cmls (setvar 'cmleaderstyle cmls))
(if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
(princ)
);end_defun


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 31 of 31

dlanorh
Advisor
Advisor

@dbhunia wrote:

Please go through the modified code........


??

I am not one of the robots you're looking for

0 Likes