Author Topic: DIMASZ Variable...  (Read 5145 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #15 on: January 27, 2010, 11:47:12 AM »
The ptLst needs to be a variant, as stated earlier.

i.e.

Code: [Select]
(setq mtxtobj (vla-addmtext mspace (vlax-3d-point pt3) 0 ""))
(setq ptLst   (apply (function append) (list pt1 pt2 pt3)))

(setq ldrObj (vlax-invoke-method mspace 'addleader (vlax-make-variant
                                                     (vlax-safearray-fill
                                                       (vlax-make-safearray vlax-vbDouble
                                                         (cons 0 (1- (length ptLst)))) ptLst))
               mtxtobj acLineWithArrow))

(vla-delete mtxtobj)


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #16 on: January 27, 2010, 03:33:32 PM »
This should help you:

Code: [Select]
(defun leader (pts txt typ / spc)
  (setq doc (cond (doc) ((vla-get-ActiveDocument
                           (vlax-get-acad-object))))

        spc (if (zerop (vla-get-ActiveSpace doc))
               (vla-get-PaperSpace doc)
               (vla-get-ModelSpace doc)))

  (cond (  (< (length pts) 2))
       
        (  (vlax-invoke-method spc 'AddLeader
             (vlax-make-variant
               (vlax-safearray-fill
                 (vlax-make-safearray vlax-vbDouble
                   (cons 0 (1- (* 3 (length pts)))))
                 (apply (function append) pts)))

              (vlax-invoke-method spc 'AddMText
                (vlax-3D-point (last pts)) 0. txt) typ))))



(defun c:test (/ ptLst pt)
  (vl-load-com)

  (if (car (setq ptLst (list (getpoint "\nFirst Point of Leader: "))))
    (progn
      (while (setq pt (getpoint (car ptLst) "\nNext Point: "))
        (setq ptLst (cons pt ptLst)))

      (leader (reverse ptLst) "Lee Mac" acLineWithArrow)))

  (princ))

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #17 on: January 28, 2010, 09:06:04 AM »
error: Automation Error. Too few elements in SafeArray
or total number of elements is not a multiple of three

I think this is my pt3:

(setq pt3 (list (car pt2)(+ (cadr pt2) land)))

where land is:

(setq land (* (getvar "dimasz") (getvar "dimscale"))) ;;;Hook Line size

I think it is getting a 2D point when I need a 3D point. I looked at the leader object in the help files for something like the dogleg for mleaders. The only thing I could find that was possible was:

vlax-3d-point

But I am unsure how to incorporate this together...

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #18 on: January 28, 2010, 10:27:06 AM »
Code: [Select]
(setq pt3 (list (car pt2)(+ (cadr pt2) land)))
Is 2D.

Code: [Select]
(setq pt3 (list (car pt2) (+ (cadr pt2) land) 0.0))
Is now 3D.

The PointsArray argument is as follows:

Quote
Variant (array of doubles); input-only
The array of 3D WCS coordinates specifying the leader.

Also, see my example above.  :-)

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #19 on: January 28, 2010, 04:16:19 PM »
Thanks Lee. I was thinking it had to be more complex than that.  :-o As a general rule of thumb, can any two functions be combined to accomplish a task?

For example:

(setq pt3 (list (car pt2)(+ (cadr pt2) land) 0.0))

which makes the landing.

In order to make that landing always horizontal, I could just add the polar funtion to it?

I've seen quite a few lisp that you have written, and quite impressive. They have good structure to them. Is there a certain structure to go about writing them?
« Last Edit: January 28, 2010, 04:20:29 PM by AWW »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #20 on: January 28, 2010, 07:53:09 PM »
Thanks Lee. I was thinking it had to be more complex than that.  :-o As a general rule of thumb, can any two functions be combined to accomplish a task?

For example:

(setq pt3 (list (car pt2)(+ (cadr pt2) land) 0.0))

which makes the landing.

In order to make that landing always horizontal, I could just add the polar funtion to it?

I've seen quite a few lisp that you have written, and quite impressive. They have good structure to them. Is there a certain structure to go about writing them?

Thanks AWW,

I tend to group my code into parts that are performing each task in turn, instead of having just one long list - it is easier to read that way.  :wink:

As for using polar, I you can combine as many LISP functions as you like, LISP is interpreted from the "inside-out"; but in my opinion, I would either use a point defined using the polar function, or define it manually using each cartesian coordinate, else things get complicated.

Lee