Jump to content

Recommended Posts

Posted (edited)

I have an old routine that I use to add data points to pipe drawings. It uses the "line" and ".solid" commands to construct the 'leader' basically. Its basic but works fine and we really have no issues. I just need it tweaked to improve it slightly but not sure how to go about it.

 

I would like the user to be able to atleast have multiple selections for the landing in case the datapoint origin point is in a tight squeeze and we need to pull the leader to get the text out of the clutter. It would also be nice to be able to have the arrow and line as a MLEADER somehow in case in the future the user needs to stretch the leader in any way it would be easier but i need the arrow to be the same size. If you have time to take a look and test it, I promise your time is greatly appreciated.

 

 

(DEFUN C:DATAPOINT( / oldlayr oldos oldortho P1A P2A DATA side1 dir1 P3A P4A A1)
(defun *error* (msg)
    (if oldlayr (setvar "clayer" oldlayr))
    (if oldos (setvar "osmode" oldos))
    (if oldortho (setvar "orthomode" oldortho))
    (if msg (prompt msg))
    (princ)
    )
   (if (null(tblsearch "LAYER" "LOCAL-DATA"))
      (command "._-layer" "N" "LOCAL-DATA" "C" "142" "LOCAL-DATA" "")
   )
  (setq oldortho (getvar "orthomode")) 
  (setq oldos (getvar "osmode"))
  (setq oldlayr (getvar "clayer")) 
  (command "._-layer" "s" "LOCAL-DATA" "")
  (setvar "osmode" 16383)
;(WHILE ;loop if user wants to continue adding more
  (initget 1)  (setq p1a (getpoint "\nSelect datapoint location on pipe: "))
  (setvar "osmode" 0)
  (setvar "orthomode" 0)
  (initget 33) (setq p2a (getpoint p1a "\nSelect datapoint label location: "))
  (setq DATA (getreal "\nEnter STARTING datapoint number: "))
  (if (not (equal p1a p2a))
  (progn
   (if (< (car p1a) (car p2a))
    (progn (setq side1 "ML") (setq dir1 0.0))
    (progn (setq side1 "MR") (setq dir1 180.0))
   )
   (setq p3a (polar p2a (dtr dir1) (getvar "userr1")))
   (setq p4a (polar p3a (dtr dir1) (getvar "userr1")))
  )
  (progn (setq p4a p2a) (setq side1 "ML")
  )
 )
   (command "._line" p1a p2a p3a "")
   (setq a1 (angle p2a p1a))
   (command "._solid" p1a (polar p1a (- a1 85) (getvar "userr1"))
                         (polar p1a (+ a1 85) (getvar "userr1")) "" "")
  (command "._text" side1 p4a (getvar "userr1") 0 (strcat "#" (trim (rtos DATA 2 0)) "- PIPE"))
  (setq DATA (+ DATA 1))
  (command "._-layer" "s" oldlayr "")
  (setvar "OSMODE" OLDOS)
  (setvar "ORTHOMODE" OLDORTHO)
;) ;end while
(*ERROR* nil)
(PRINC))

 

Edited by tmelancon
Posted

Have you not answered your own question and use a Mleader for the task ?

Posted

 

(vl-cmdf "_LEADER"
                "non" p1a "non" p2a "" (strcat "#" (trim (rtos DATA 2 0)) "- PIPE")
                ""
      )

trim ? BCAD?

Posted

BIGAL thanks for your input. I understood I could use something like Mleader, however, I was not aware of how to structure the code and get started to incorporate that function.

 

hanhphuc thanks this is exactly what I was looking for. Revised my code, made a few other adjustments, and it works flawlessly. God bless you for your valuable time!

Posted

"I was not aware of how to structure the code and get started"

 

Whilst you have the answer for future reference most of us here just get a pencil and paper or copy the command history to see the manual sequence of what is required in a lisp version.

Posted
On 6/16/2020 at 12:10 AM, tmelancon said:

BIGAL thanks for your input. I understood I could use something like Mleader, however, I was not aware of how to structure the code and get started to incorporate that function.

 

hanhphuc thanks this is exactly what I was looking for. Revised my code, made a few other adjustments, and it works flawlessly. God bless you for your valuable time!

 

FWIW vla-addleader method is well documented

RetVal = object.AddLeader(PointsArray, Annotation, Type)

 

Object - ModelSpace collection, PaperSpace collection, Block
The object or objects this method applies to.

 

PointsArray - Variant (array of doubles); input-only
The array of 3D WCS coordinates specifying the leader. You must provide at least two points to define the leader. The third point is optional.

 

Annotation - Object; input-only. A Tolerance, MText, BlockRef object or NULL.

 

Type

AcLeaderType enum; input-only

acAttributeModeLockPosition

acAttributeModeMultipleLine

acLineNoArrow

acLineWithArrow

acSplineNoArrow

acSplineWithArrow

 

RetVal 

Leader object
The newly created Leader object.

 

Remarks

The leader is a line that connects some annotation to a feature in a drawing. Leaders and their annotation are associative, which means if you modify the annotation, the leader updates accordingly. The annotation can be a Tolerance, Mtext, or BlockRef object.

You can also create leaders that are not associated to a particular object. To do this, simply input a NULL object as the annotation.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...