Author Topic: Area reactor  (Read 33926 times)

0 Members and 2 Guests are viewing this topic.

MvdP

  • Guest
Re: Area reactor
« Reply #45 on: June 14, 2006, 03:48:03 AM »
I tried it all  and it is not going the way i want and should.

- The cond section is not working, the variables "anghatch" and "dblhatch" are not set.
- The polyline only selection is not working it returns an error 

  bad argument type: consp <Entity name: 7e258c68> 

Once again i can't figure it out what i am doing wrong.


Code: [Select]
; DDlabelArea.lsp

(defun c:ddla (/ area1 area2 tab oba inspoint objarea)

(setq areanamelist(list
""
"Verblijfsgebied A"
"Verblijfsgebied B"
"Verblijfsgebied C"
"Verblijfsgebied D"
"Verblijfsgebied E"
"Verblijfsgebied F"
"Verblijfsgebied G"
"Verkeersgebied"
"Onbenoemde Ruimte"
"Badkamer"
"Toilet"
))

(setq rotationlist(list
"0"
"45"
"90"
"135"
"180"
"225"
))

; ************************************************
  (defun txtbox_infohulp ()
    (alert
      (strcat
        "DDLabelArea 2006 Help.\n\n"
        "Please report any problems you may have.\n\n"
       )
    )
  )
; ************************************************

(setq DDLA (load_dialog "DDlabelarea"))
(new_dialog "DDlabelarea" DDLA)
(start_list "areanamelist")
(mapcar 'add_list areanamelist)
(end_list)

(start_list "rotationlist")
(mapcar 'add_list rotationlist)
(end_list)

; ************************************************
(defun do_hatch ()
  (if (=  (get_tile "do-hatch") "1")(setq hatch-area "J"))
  (if (/= (get_tile "do-hatch") "1")(setq hatch-area "N"))
)
; ************************************************

(action_tile "accept" "(setq area-name (get_tile \"areanamelist\"))(setq rotation (get_tile \"rotationlist\"))(done_dialog 1)")
(action_tile "do-hatch" "(do_hatch)")
(action_tile "hulp" "(txtbox_infohulp)")
(action_tile "cancel" "(exit)(exit)")
(setq RET (start_dialog))}

  (setvar "cmdecho" 1)
  (setq fd (getvar "fielddisplay"))
  (if (/= fd 1)(setvar"fielddisplay" 1))


;;(setq area1 (entsel "\nSelect Area Boundary: "))
(while (not (setq ss (ssget ":e:s" '((0 . "LWPOLYLINE") (70 . 1))))))
(setq area1 (ssname ss 0))

(setq area2 (car area1))
(setq tab (vlax-ename->vla-object area2))
(setq oba (vla-get-objectid tab))


(princ)
(setq inspoint (getpoint "\nPick label insertion point:  "))
(princ)
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr2%ps[, m2]%ds44%ct8[1e-006]\">%"))
(setvar "attdia" 0)
(setvar "attreq" 1)
(setq schaal (rtos(getvar "userr1")))
(command "-insert" "oppervlakte" "s" schaal inspoint (nth (atoi rotation) rotationlist) (nth (atoi area-name) areanamelist) objarea )

(setq hatchobjects(entlast))

(command "-layer" "s" "00---0-a_Arceer" "")

  (cond
((= area-name "Verblijfsgebied A")(setq anghatch "45") (setq dblhatch "n"))
((= area-name "Verblijfsgebied B")(setq anghatch "45") (setq dblhatch "n"))
((= area-name "Toilet")           (setq anghatch "135")(setq dblhatch "n"))
((= area-name "Verkeersgebied")   (setq anghatch "45") (setq dblhatch "y"))
 )

  (if (= hatch-area "J")(command "-bhatch" "s" area1 hatchobjects "" "p" "u" anghatch "150" dblhatch ""))

 
(setq hatch-area nil )
(setq hatchobjects nil )
(setq anghatch nil )
(setq dblhatch nil)
(command "-layer" "s" "0" "")
 
(setvar "attdia" 1)
(setvar "attreq" 1)
  (princ)
)



Code: [Select]
DDlabelarea : dialog {
value = "DDLabelArea 2006";
key = "title";
:boxed_row { label = "< Select Area Name >";
:popup_list { key = "areanamelist"; width = 30;}}

:spacer{height=1;}

:row{
:boxed_row { label = "< Rotation >";
:popup_list {key = "rotationlist";   fixed_width = true;  width = 5;  }}
:boxed_row { label = "< Hatch > ";
:spacer{height=2;}
:toggle { label = "Yes"; key = "do-hatch";mnemonic = "Y";}}}

:row{
:button{label="Sel. Object ";width   =10;height = 1.4;key="accept";mnemonic = "S";}
:button{label="Help"        ;width   =10;height = 1.4;key="hulp"  ;mnemonic = "H";}

:spacer{height=5;}

cancel_button;
}
}

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Area reactor
« Reply #46 on: June 14, 2006, 06:00:39 AM »
.. and which line did the error occur on .. ?

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gerstal82

  • Guest
Re: Area reactor
« Reply #47 on: June 14, 2006, 07:13:33 AM »
When I run the lisp 'area1' returns:
_$ area1
<Entity name: 7ef71ea8>
_$

So --> (setq area2 (car area1))
has to be --> (setq area2 area1)


MvdP

  • Guest
Re: Area reactor
« Reply #48 on: June 14, 2006, 07:58:54 AM »
Kerry Brown the error  occurred after selecting the polyline and thanks gerstal82 that worked.(don't know the difference)


But how to do this.

Prompt on the command line to select closed polyline                               "\nSelect Area Boundary: "
Prompt on the command line when selected object is not a closed polyline   "\nError selected object is NOT a Closed LWpolyline.
Prompt on the command line when nothing is selected.  "\nNothing selected..........."
« Last Edit: June 14, 2006, 08:56:22 AM by MvdP »

gerstal82

  • Guest
Re: Area reactor
« Reply #49 on: June 14, 2006, 09:01:59 AM »
You can try this to see if a polyline is closed or not
http://discussion.autodesk.com/thread.jspa?messageID=1187865

MvdP

  • Guest
Re: Area reactor
« Reply #50 on: June 14, 2006, 09:31:01 AM »
The code T.Willey  posted already sees if a polyline is closed or not,but i like a prompt on the command line
when a certain selected object is not a closed polyline   "\nError selected object is NOT a Closed LWpolyline.


T.Willey

  • Needs a day job
  • Posts: 5251
Re: Area reactor
« Reply #51 on: June 14, 2006, 11:19:21 AM »
Code: [Select]
(prompt "\nSelect Area Boundary: ")
(while (not (setq ss (ssget ":e:s" '((0 . "LWPOLYLINE") (70 . 1)))))
 (prompt "\n Object selected is NOT an LWPolyline. ")
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Area reactor
« Reply #52 on: June 14, 2006, 11:45:20 AM »
Thanks Tim.

Any thoughts on the problem i am having in the conditions section , the variables "anghatch" and "dblhatch" are not being set..

When i do (princ area-name) on commandline it returns a number f.i. toilet returns 3..

Code: [Select]
(cond
((= area-name "Verblijfsgebied A")(setq anghatch "45") (setq dblhatch "n"))
((= area-name "Verblijfsgebied B")(setq anghatch "45") (setq dblhatch "n"))
((= area-name "Toilet")           (setq anghatch "135")(setq dblhatch "n"))
((= area-name "Verkeersgebied")   (setq anghatch "45") (setq dblhatch "y"))
)

not even when i do this


Code: [Select]
(command "-bhatch" "s" area1 hatchobjects "" "p" "u" anghatch "150" dblhatch "")
instead of this.

Code: [Select]
(if (= hatch-area "J")(command "-bhatch" "s" area1 hatchobjects "" "p" "u" anghatch "150" dblhatch ""))
Another thing i thought would be working but is not is this.make default do-hatch on with value ="1"(see code below) and uncheck (toggle) if you dont want the object to be hatched, but it do not hatch anything.

Code: [Select]
:toggle { label = "Yes"; key = "do-hatch";mnemonic = "Y";value = "1";}

« Last Edit: June 15, 2006, 08:59:38 AM by MvdP »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Area reactor
« Reply #53 on: June 14, 2006, 12:36:24 PM »
I will look more into this when I get a chance, right now REAL (drafting, phttts...) work calls.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Area reactor
« Reply #54 on: June 16, 2006, 07:55:01 AM »
I thought i got it but,this

Code: [Select]
((= (nth (atoi area-name) areanamelist) "1")(setq anghatch "135")(setq dblhatch "n"))
or this
Code: [Select]
((= (nth (atoi area-name) areanamelist) "Badkamer")(setq anghatch "135")(setq dblhatch "n"))
isn't working either.!!!

MvdP

  • Guest
Re: Area reactor
« Reply #55 on: June 16, 2006, 02:48:00 PM »
I have another question is there something like an and in conditions in lisp .f.i.

Code: [Select]
((= a "b") and (= c "d") (setq w "x") (setq y "z"))

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Area reactor
« Reply #56 on: June 16, 2006, 02:55:39 PM »
This one is quick.  Yes.

Code: [Select]
(cond
 (
  (and
   (equal 1 1)
   (equal 2 2)
  )
  (princ "\n True")
 )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Area reactor
« Reply #57 on: June 16, 2006, 03:06:50 PM »
Got no access to AutoCAD right now,so if understand it correctly it would look like this.?

Code: [Select]
(cond
(and(= suffix "suffix1")(= prec "0.0")
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr1%ps[, m2]%ds44%ct8[1e-006]\">%")))
(and(= suffix "suffix1")(= prec "0.00")
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr2%ps[, m2]%ds44%ct8[1e-006]\">%")))
(and(= suffix "suffix1")(= prec "0.000")
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr3%ps[, m2]%ds44%ct8[1e-006]\">%")))
(and(= suffix "suffix1")(= prec "0.000")
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr4%ps[, m2]%ds44%ct8[1e-006]\">%")))
(and(= suffix "suffix1")(= prec "0.0000")
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr5%ps[, m2]%ds44%ct8[1e-006]\">%"))
)
)


And so on...
« Last Edit: June 16, 2006, 03:20:20 PM by MvdP »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Area reactor
« Reply #58 on: June 16, 2006, 03:24:54 PM »
Nope.  You have your and statement set up wrong.  You have to have it set up like this

Code: [Select]
(cond
 ( ; This is the first test
  (and ; You are saying you want to test more than one condition, and you want them to both be true
   (equal 1 1)
   (equal 2 2)
  ) ; End your and statement
  (prompt "\n True")
 ) ; End the first operation of the cond
So yours would look like
Code: [Select]
(cond
( ; <- added
(and
(= suffix "suffix1")(= prec "0.0")
) ;<- added
(setq objarea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos oba 2 0) ">%).Area \\f \"%lu2%pr1%ps[, m2]%ds44%ct8[1e-006]\">%"))
) ; <- added
... the rest of your code....
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MvdP

  • Guest
Re: Area reactor
« Reply #59 on: June 16, 2006, 03:29:53 PM »
OK Thanks i got it..