Author Topic: Dimassoc Value  (Read 8385 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Dimassoc Value
« Reply #15 on: March 02, 2011, 08:37:59 PM »
how are you stopping the while loop?  if you are hitting Esc then, no, the value will not be reset since pressing Esc is considered an error. For the value to be reset when the user hits Esc you would need an error handler - there is a tutorial on my site where you can learn how to create one.

Have you tried exiting the program by pressing enter?

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Dimassoc Value
« Reply #16 on: March 02, 2011, 08:41:36 PM »
how are you stopping the while loop?  if you are hitting Esc then, no, the value will not be reset since pressing Esc is considered an error. For the value to be reset when the user hits Esc you would need an error handler - there is a tutorial on my site where you can learn how to create one.

Have you tried exiting the program by pressing enter?

No, but right-click the mouse.
It equals to "enter".
« Last Edit: March 02, 2011, 09:07:05 PM by MeasureUp »

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Dimassoc Value
« Reply #17 on: March 03, 2011, 12:37:22 AM »
Actually I added a line in red for testing:
Code: [Select]
(defun c:test ( / ass elast )

  (setq ass (getvar 'DIMASSOC))
  (initget "0 1 2")
  (setvar 'DIMASSOC (atoi (cond ( (getkword "\nSpecify DIMASSOC Value [0/1/2] <1>: ") ) ( "1" ))))

  (prompt (strcat "\nDIMASSOC Value = " (itoa (getvar 'DIMASSOC))))

  (setq elast t)
  (while (not (equal elast (setq elast (entlast))))
    (command "_.dimlinear" pause pause pause)
  )
  (setvar 'DIMASSOC ass)
[color=red](prompt (strcat "\nDimAssoc Value = " (itoa (getvar 'DIMASSOC)) "\n"))[/color]

(princ)
)
Again I preset the drawing with "dimassoc" to 1 and below is what I have from the textscreen:

Quote
...
Command:
_.dimlinear
Specify first extension line origin or <select object>:
Specify second extension line origin:
Specify dimension line location or
[Mtext/Text/Angle/Horizontal/Vertical/Rotated]:
Dimension text = 478
Command:
DimAssoc Value = 2
_.dimlinear
Specify first extension line origin or <select object>: <= Press "enter" here

Select object to dimension: <= Press "enter" here again



Command: <= Press "enter" again here
TEST Unknown command "TEST".  Press F1 for help.

Command:

DimAssoc Value = 1

The question is why I have to press the "enter" 3 times to stop the code running?
« Last Edit: March 03, 2011, 07:57:37 PM by MeasureUp »

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Dimassoc Value
« Reply #18 on: March 03, 2011, 07:55:38 PM »
This is really frustrated.
Can anyone help please?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Dimassoc Value
« Reply #19 on: March 03, 2011, 07:59:13 PM »
Use this instead:

Code: [Select]
(defun c:test ( / ass p1 )

  (setq ass (getvar 'DIMASSOC))
  (initget "0 1 2")
  (setvar 'DIMASSOC (atoi (cond ( (getkword "\nSpecify DIMASSOC Value [0/1/2] <1>: ") ) ( "1" ))))

  (prompt (strcat "\nDIMASSOC Value = " (itoa (getvar 'DIMASSOC))))

  (while (setq p1 (getpoint "\nSpecify First Point <Exit> : "))
    (command "_.dimlinear" "_non" p1 pause pause)
  )
  (setvar 'DIMASSOC ass)
  (princ)
)

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Dimassoc Value
« Reply #20 on: March 03, 2011, 08:16:23 PM »
Thanks Lee.
It works now.  :-)

In the previous one you tried to compare two selected entities.
Can you explain why the previous one doesn't do the job properly?
I notice that while functions works if using a defined point as the condition.
I also use this before without any problems.
Thanks again.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Dimassoc Value
« Reply #21 on: March 03, 2011, 08:29:29 PM »
The previous code didn't work because the DimLinear command has a default option "<Select Object>" that was being selected when the user pressed Enter.

If this default option didn't exist, the previous version would have worked as well.

FYI: I was not comparing two 'selected entities', I was comparing the last entity created in the drawing database before the DimLinear command is called with the last entity created after the command is called. The While condition would only continue if such entities differed, hence if the DimLinear command successfully added an entity to the drawing database.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Dimassoc Value
« Reply #22 on: March 03, 2011, 09:54:33 PM »
Yes, you are right.
Thanks for your help.  :laugh: