Lisp Modification

Lisp Modification

thomas_huntFMPXR
Contributor Contributor
324 Views
1 Reply
Message 1 of 2

Lisp Modification

thomas_huntFMPXR
Contributor
Contributor
Been trying to aimplement annotaive scale and text height into lisp but with no luck.  and tips for adding the function to this code?
 
(defun c:ldr (/ lyr annoscale mleaderstyle pt)

  ;; Settings
  (setq lyr "PV-TEXT-NOTE")
  (command "_.annoscale" "_S" "1:30" "1:15" "1:10")
  (command "_.mleaderstyle" "annoleaderstyle")
 
    ;equipment pad 1
(setq pt (getpoint "\nEQUIPMENTPAD1"))
  (command "mleader" pt pause "EQUIPMENT PAD 1")
 
;equipment pad 2
(setq pt (getpoint "\nEQUIPMENTPAD2"))
  (command "mleader" pt pause "EQUIPMENT PAD 2")
 
;(e)structure
(setq pt (getpoint "\nSTRUCTURE"))
  (command "mleader" pt pause "(E) STRUCTURE")

);end defun
0 Likes
Accepted solutions (1)
325 Views
1 Reply
Reply (1)
Message 2 of 2

paullimapa
Mentor
Mentor
Accepted solution

There are a number of problems to your code but it's very easy to check what the problems are:

(1) All this does is set this text string "PV-TEXT-NOTE" to a variable called lyr 

(setq lyr "PV-TEXT-NOTE")

But lyr is never used anywhere else in the code.

If you want your MLeaders to be created on this layer and assuming this layer already exists then you should at least have a line of code like this which sets the current layer to that text string:

(setvar "CLAYER" "PV-TEXT-NOTE")

or

(setvar "CLAYER" lyr)

(2) what is this line of code supposed to do:

(command "_.annoscale" "_S" "1:30" "1:15" "1:10")

To test, just enter it at the command line and you'll see the results:

paullimapa_0-1750210833644.png

Notice the correct entry is CANNOSCALE

And then AutoCAD is expecting a scale as the response like 1:30 but not "_S" which will return *Invalid*

So the following line of code would be use to set the current Cannoscale to 1:30:

(command "_.Cannoscale" "1:30")

(3) The following line of code does NOT set the current Mleader Style to "annoleaderstyle

(command "_.mleaderstyle" "annoleaderstyle")

But instead the MLeaderStyle command actually brings up the Multileader Style Manager:

paullimapa_1-1750211329023.png1

If you want to set the Mleader Style to an existing style called "annoleaderstyle" then do the following:

(setvar "CMLEADERSTYLE" "annoleaderstyle")

To make life easy your Mleaderstyle "annoleaderstyle" should already be set up with all the annotative properties:

Enter the command MLeaderstyle and do the following:

1) Leader Structure>Scale: toggle Annotative on:

paullimapa_3-1750212361538.png

 

2) Content tab>Text options>Text style: the text style selected should have annotative properties. In this example the Text Style Annostyle is set with Annotative enabled:

paullimapa_2-1750212194266.png

 

Now when you execute your getpoint function & then the Mleader command you'll successfully create the Mleader on the proper layer with annotative properties:

(setq pt (getpoint "\nEQUIPMENTPAD1"))
  (command "mleader" pt pause "EQUIPMENT PAD 1")

Note: You may want to look up the importance of setting ANNOAUTOSCALE to 4:

(setvar "ANNOAUTOSCALE" 4)

paullimapa_4-1750212593529.png


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos