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

0 Members and 1 Guest are viewing this topic.

AWW

  • Guest
DIMASZ Variable...
« on: January 12, 2010, 12:13:44 PM »
Via AutoCAD 2008 Help:

Controls the size of dimension line and leader line arrowheads. Also controls the size of hook lines.

I'm focusing on the hook lines with this code:

(setq land (* (getvar "dimasz") (getvar "dimscale")))

Trying to get pt2 and add the landing gap automatically:

(setq pt3 (+ (getpoint pt2 (* (getvar "dimasz") (getvar "dimscale")))

or

(setq pt3 (+ (getpoint pt2) (land))

I can't be that far off, but it seems everything I try is off. I know how
to get autocad defined variables with getvar. Does that also work for the ones
that are created manually? What am I missing?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #1 on: January 12, 2010, 12:38:59 PM »
You want to look into the polar function

GetPoint is for prompting the user for a point selection  :wink:

Crank

  • Water Moccasin
  • Posts: 1503
Re: DIMASZ Variable...
« Reply #2 on: January 12, 2010, 01:06:47 PM »
What am I missing?
1) Only the first line of lisp will work
2) You are trying to add a distance to coordinates.

If you just want a angle of 90 degrees, your code would be something like:
Code: [Select]
(setq p2 (getpoint))
(setq p3 (list (car p2)(+ (cadr p2) land)))
You can improve this with the use of the functions POLAR and TRANS.

(getvar "DIMSCALE") worked fine until Acad2008. Because that release also offers annotative scaling, it's better to replace this with a function that handles the scale:
Code: [Select]
(defun b=sch ()
(if (and (zerop (getvar "TILEMODE"))(zerop (getvar "VPMAXIMIZEDSTATE"))(eq (getvar "CVPORT") 1))
1.0
; else
(progn
(if (zerop (getvar "DIMANNO"))
(if (zerop (getvar "DIMSCALE")) 1.0 (getvar "DIMSCALE"))
(/ 1.0 (getvar "CANNOSCALEVALUE"))
)
)
)
)
If your dimstyle is annotative, this will use the annoscale, if it's not annotative it will still use the DIMSCALE.

If you have 2008 I wouldn't use the old leaders any more, because Mleaders are much better.
Vault Professional 2023     +     AEC Collection

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #3 on: January 12, 2010, 01:50:55 PM »
LeeMac: I realized that at about the getpoint. I thought the getpoint could actually just get a point without user input as 
            well. Guess I get mixed up about what to use sometimes.  :oops:

Crank: I did not know that about dimscale in 2008. Thanks for todays lesson! lol
« Last Edit: January 12, 2010, 01:54:33 PM by AWW »

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: DIMASZ Variable...
« Reply #4 on: January 12, 2010, 09:45:21 PM »

(getvar "DIMSCALE") worked fine until Acad2008. Because that release also offers annotative scaling, it's better to replace this with a function that handles the scale:
Code: [Select]
(defun b=sch ()
(if (and (zerop (getvar "TILEMODE"))(zerop (getvar "VPMAXIMIZEDSTATE"))(eq (getvar "CVPORT") 1))
1.0
; else
(progn
(if (zerop (getvar "DIMANNO"))
(if (zerop (getvar "DIMSCALE")) 1.0 (getvar "DIMSCALE"))
(/ 1.0 (getvar "CANNOSCALEVALUE"))
)
)
)
)
If your dimstyle is annotative, this will use the annoscale, if it's not annotative it will still use the DIMSCALE.


Interesting Crank.  I will have to give that one some thought
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #5 on: January 26, 2010, 01:02:52 PM »
I've been flirting with this landing, trying to get it to work properly. I had thought about using polar, but the more I thought about it, the more I realized that the landing isn't always going to be 90 degress. The angle isn't what I am after, it's the horizontal landing line to the left or to the right, whatever angle it may turn out to be.

Right now I'm using:

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

But when I get to:

(setq mtxtobj (vla-addmtext mspace (vlax-3d-point pt3) 0 ""))
(setq ldrObj (vlax-invoke-method mspace 'addleader ptlist mtxtobj acLineWithArrow))

I seem to get errors about a variant and safearrays, which I haven't used. Instead, I used:

(setq ptlist (apply 'append (list pt1 pt2 pt3)))

Any suggestions?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #6 on: January 26, 2010, 03:56:08 PM »
The "points array" argument in the addleader method needs to be a variant.

Something like:

Code: [Select]
(setq ptLst (apply (function append) (list pt1 pt2 pt3)))

(vlax-make-variant
  (vlax-safearray-fill
    (vlax-make-safearray vlax-vbDouble
      (cons 0 (1- (length ptLst)))) ptLst))

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #7 on: January 27, 2010, 08:18:29 AM »
Thanks Lee. One question... the function can be any function in (function append)?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #8 on: January 27, 2010, 08:19:48 AM »
Thanks Lee. One question... the function can be any function in (function append)?

Sorry, not sure what you mean? Function is an AutoLISP function in itself  :-)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #9 on: January 27, 2010, 09:31:26 AM »
That is what I meant, any autocad funtion. I have only seen mapcar and lambda used there.

No, 'function' is a function in AutoLISP - look it up in the VLIDE help files  :wink:  It declares 'append' as a function.


AWW

  • Guest
Re: DIMASZ Variable...
« Reply #10 on: January 27, 2010, 09:37:46 AM »
Ok. I see. Is it still Monday?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #11 on: January 27, 2010, 10:05:33 AM »
Ok. I see. Is it still Monday?

 :-D

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #12 on: January 27, 2010, 10:10:48 AM »
The reason I asked was that I seem to get:

error: Upper bound in SAFEARRAYBOUND occurred to be less
than lower.

What does that mean?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DIMASZ Variable...
« Reply #13 on: January 27, 2010, 10:27:30 AM »
That would occur if (length ptLst) = 0.

AWW

  • Guest
Re: DIMASZ Variable...
« Reply #14 on: January 27, 2010, 11:37:36 AM »
Ok. I got the above code to work. But it doesn't seem to recognize it for some reason when I get here:

  (setq mtxtobj (vla-addmtext mspace (vlax-3d-point pt3) 0 ""))
  (setq ldrObj (vlax-invoke-method mspace 'addleader ptLst mtxtobj acLineWithArrow))
  (vla-delete mtxtobj)

I get this: lisp value has no coercion to VARIANT with this
type:  (2231.13 1060.76 0.0 2293.22 1183.58 0.0 2293.22 1188.58)

Just by looking at this, it seems like the last point (pt3) is a 2d point instead of a 3d point. Correct?