(vla-put-AttachmentPoint vla_mtx attachPointFromExistingMText)
(vla-put-AttachmentPoint newMText attachPointFromExistingMText) InsertioinPointForMText widthForMText textForMText)) (setq modelSpace (vla-get-ModelSpace doc)) (setq doc (vla-get-ActiveDocument acadObj)) (setq insertioinPointForMText (vla-get-insertionpoint vla_mtx)) (setq widthForMText (vla-get-width vla_mtx))
(setq textForMText (vla-get-TextString vla_mtx)) (vla-put-AttachmentPoint vla_mtx acAttachmentPointTopLeft) This is will make the insertion point correct for the new MText change the attachmentPoint for existing leader to Top Left (setq attachPointFromExistingMText (vla-get-attachmentpoint vla_mtx)) Store the current attachmentpoint of the existing MText (setq points (vlax-make-safearray vlax-vbDouble (setq arrayForPoints (cons 0 numberOfPoints)) (setq numberOfPoints (1- (length coords))) (setq coords (vlax-get vla_ldr 'Coordinates)) Get the coordinates from the existing leader Vla_mtx (vlax-ename->vla-object (ssname ss1 0)) (setq vla_ldr (vlax-ename->vla-object (ssname ss1 1)) Vla_mtx (vlax-ename->vla-object (ssname ss1 1)) (setq vla_ldr (vlax-ename->vla-object (ssname ss1 0)) (if (= (cdr (assoc 0 (entget (ssname ss1 0)))) "LEADER") Have a Leader and MText get the ActiveX Object (while (setq ss1 (ssget (list (cons -4 "")))) TextForMText widthForMText insertioinPointForMTextÄrawingDirectionForMText newLeader verticalTextPosition) (defun C:copyLeaderTest (/ vla_ldr vla_mtx coords numberOfPointsĪrrayForPoints points attachPointFromExistingMText This example is just getting the points from the existing leader, the MText, and then creating a new Leader at the same location. After you run the function you will need to move the Leader manually to see that there are are two leaders at the same location.Īnother way to do this would be to use the Copy method and set the annotation property. When you run this example you select a leader and the MText annotation for the leader.
Autocad lisp line transparency how to#
Recently I had a case where the question was how to create a new leader based on an existing leader using AutoLISP. 0 "AUTOCAD" ) ) ( vla-put-attachmentPoint mtextobj acAttachmentPointMiddleCenter ) ( vla-put-insertionPoint mtextobj ( vlax-3d-point entpt ) ) ( vla-put-Rotation mtextobj ang ) ( vla-put-Height mtextobj hght ) ( vla-put-Color mtextobj 7 ) ( vla-put-backgroundfill mtextobj :vlax-true ) 5 ) ) ) ( setq ang ( + ang pi ) ) ) ( setq hght ( getreal "\nText Height : " ) ) ( setq mspace ( vla-get-modelspace ( vla-get-activedocument ( vlax-get-acad-object ) ) ) ) ( setq mtextobj ( vla-addMText mspace ( vlax-3d-point entpt ) 0. ( vl-load-com ) ( setq es ( entsel ) entpt ( osnap ( cadr es ) "_nea" ) ang ( angle ' ( 0 0 0 ) ( vlax-curve-getFirstDeriv ( vlax-ename- > vla-object ( car es ) ) ( vlax-curve-getParamAtPoint ( vlax-ename- > vla-object ( car es ) ) entpt ) ) ) ) ( if ( and ( > ang (/ pi 2 ) ) ( < = ang ( * pi 1. The key to finding the rotation is to determine the first derivative (slope) of the curve at the point the entity was selected. Since this requirement of aligning an MText along a curve is quite essential in Civil / Survey applications, I am posting a bare-bone implementation of it that you can customize. Kent Cooper's nice reply in that forum post provides all that is necessary to implement that. In this discussion forum post, the developer wanted an MText to align automatically with the curve without having to provide additional inputs for specifying the rotation.