Jump to content

HVAC drawings


viviancarvalho

Recommended Posts

Viv,

 

I did not mess around with the code as much as i should have. I took for granted that the figure for object snap mode 128 was what you wanted as I saw this in your code. After lookung it up, It only sets perpedicular snap to be active. There are two locations in the code where the snaps are turned on.

 

Befor selecting the insertion point and Before rotating the object.

 

I do not think this will cut it for you. I set the object snap for these as follows.

 

(setvar "osmode" 16383) ;Turn on all object snaps

 

You can edit this yourself or download the attached zip.

Sorry about that, But I should have tested it more.

 

This section on object snap mode is from the Acad Help Section.

 

Type: Integer

Saved in: Registry

Initial value: 4133

 

Sets running Object Snap modes using the following bitcodes:

 

0 NONe

1 ENDpoint

2 MIDpoint

4 CENter

8 NODe

16 QUAdrant

32 INTersection

64 INSertion

128 PERpendicular

256 TANgent

512 NEArest

1024 QUIck

2048 APParent Intersection

4096 EXTension

8192 PARallel

 

To specify more than one object snap, enter the sum of their values. For example, entering 3 specifies the Endpoint (bitcode 1) and Midpoint (bitcode 2) object snaps. Entering 16383 specifies all object snaps.

 

When object snaps are switched off using the Osnap button on the status bar, a bitcode of 16384 (0x4000) is returned, in addition to the normal value of OSMODE. With this additional value, developers can write applications for AutoCAD, and distinguish this mode from Object Snap modes that have been turned off from within the Drafting Settings dialog box. Setting this bit toggles running object snaps off. Setting OSMODE to a value with this bit off toggles running object snaps on.

SAG4.zip

Link to comment
Share on other sites

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    24

  • viviancarvalho

    15

  • CarlB

    1

Hey Buzz

I liked that attitude too much & also the concept.

 

A LIGHTED CANDLE LOOSES NOTHING BY LIGHTING ANOTHER ONE

 

Thanks once again

Link to comment
Share on other sites

Hey Buzz

I liked that attitude too much & also the concept.

 

A LIGHTED CANDLE LOOSES NOTHING BY LIGHTING ANOTHER ONE

 

Thanks once again

 

 

I like that!

 

Anyway, We are not quite done yet. We can take this code beyond what you have seen so far. I was thinking of DCL (Dialog Control Langage) with preset user inputs that you just select from a list and of course the settings will be remembered each time. We can also have attributes in the block that will be filled in automatically based on the user selection. The program will also have a built-in loop function keeping the program running if you have more than one block you wish to put in. When you are done, Just hit the Cancel button. And finally we can add an image of the object that changes display also based on the user selection as well giving the user confirmation as to what is suppose to show up. The block name can also be present on the dialog also based on selection as well.

 

I know this sounds like alot, But it is possible. Some parts of the main function will look completely different since the program needs to communicate with the dialog. This will give you plenty to digest, But it will show you what some persistence can do. A program designed in this manner helps to prevent all possible user errors and speeds up the process of getting your work done much faster than a command prompt type program.

 

This will be your ultimate program. You would just need to supply me with some information such as standard metric size grilles and the name of your text layer for the attributes.

 

Below in my signature, The first program will give you an idea as to what I mean. You only need to make sure that both files are in the acad support search path.

 

I hope you are up to this.

The Buzzard

Link to comment
Share on other sites

To give you an idea of program looping, I modified the SAG4.lsp to SAG5.lsp and installed a Program Loop Function. I am sure you know that this is your program with a loop and no DCL.

 

I am sorry for taking you down such a long road, But I wish for you to absorb this in smaller pieces to make this easier on you.

 

See the attached SAG5.lsp zip file and take this one for a test to see if you like it. It sure beats typing the program syntax over and over when you have many of these objects to put in place. The program ends when you decide to end it. What you are witnessing is your program evolving very quickly.

 

As far as the DCL I mentioned, I will leave that up to you to decide if you want to go down that road.

 

Enjoy this one for now,

The Buzzard

SAG5.zip

Link to comment
Share on other sites

Buzz .

This is a nice one. The basic goal for developing this program was to save time that is spent in finding the right size block everytime. I just got the idea started off & came a long way with you in more better way than i ever imagined.But i dont want to go ahead for DCL. The reason for this is ,it will increase the user input time. In any type of HVAC dwg i make i ve to insert a number of blocks. Actually just drawing them using lisp is easy but i wanted to convert these into blocks that are named depending on their sizes. So that after i finish the dwg i can get the quantities using the "BCOUNT" command. Now i am heading towards some other blocks which i want to be treated in the same way. I ll try to do it myself till i get stuck. You are always there with a helping hand.

 

Thanks & regards

Vivian.

Link to comment
Share on other sites

Buzz .

This is a nice one. The basic goal for developing this program was to save time that is spent in finding the right size block everytime. I just got the idea started off & came a long way with you in more better way than i ever imagined.But i dont want to go ahead for DCL. The reason for this is ,it will increase the user input time. In any type of HVAC dwg i make i ve to insert a number of blocks. Actually just drawing them using lisp is easy but i wanted to convert these into blocks that are named depending on their sizes. So that after i finish the dwg i can get the quantities using the "BCOUNT" command. Now i am heading towards some other blocks which i want to be treated in the same way. I ll try to do it myself till i get stuck. You are always there with a helping hand.

 

Thanks & regards

Vivian.

 

 

Not a problem, But a DCL is just as fast and more reliable in terms of correct user input and all inputs are in one place so you do not need to anticipate what prompts are going to be next. The methods you have now put you in a very good position to make other programs of the same nature and still will be big time savers.

 

You are off to a good start.

So thats it for now.

Good Luck with your programs.

The Buzzard

Link to comment
Share on other sites

Viv,

 

I made some more revisions to your program. Essentially the program works the same, However I found some minor things that could be changed to improve the performance of the code.

 

If you have any questions about this, I will be glad to answer.

I just want to make sure your code is set to work as best as possible and for you to have a proper example to work from.

 

All revisions are listed in your header and this code is now SAG6.lsp

 

Here is the header:

;/////////////////////////////////////////////////////////////////////////////////////////
;;;
;;; Program Name: SAG6.lsp 10/29/09
;;;
;;; Author: Vivian Carvalho
;;;
;;; Program Description: Supply Air Grille Lisp
;;;
;;; Creates Metric Supply Air Grilles as a block.
;;; Program starts by saving all user settings. The program then draws a short extension
;;; of the duct as lines and inserts the grille at the end of the duct. Just enter size
;;; in mm, flow direction L ~ Left or R ~ Right and insertion point. After insertion you
;;; are requested for a rotation angle. The program will then loop requesting a Y ~ Yes or
;;; N ~ No if you wish to continue or not. When the program ends, It will restore all
;;; user Settings.
;;;
;;; Command Syntax: SAG6
;;;
;;; Note: Variables with # at the end indicate Integer.
;;;       Variables with $ at the end indicate String.
;;;
;;;
;;; Revisions - 11/05/09:
;;;
;;; 1. Changed getreal to getint in the Grille Width input.
;;; 2. Changed all if statements to cond.
;;; 3. Added # & $ to variables that handle numbers & strings.
;;; 4. Relocated Layer call before the block tblsearch & move it before the insert command.
;;; 5. Removed insert, layer call & select command from the end of block definition function.
;;; 6. Renamed program & local functions from SAG5 to SAG6.
;;;____________________________________________________
;;;| No. | Function Name | Function Description        |
;;;|_____|_______________|_____________________________|
;;;| F01 | SAG6          | Start-Up Function           |
;;;| F02 | SAG6_MF       | Main Function               |
;;;| F03 | SAG6_PL       | Program Loop Function       |
;;;| F04 | SAG6_RUS      | Restore User Settings       |
;;;| F05 | SAG6_BD       | Block Definition Function   |
;;;| F06 | SAG6_DTR      | Degrees To Radians Function |
;;;| F07 | SAG6_ML       | Make Layer Function         |
;;;| F08 | SAG6_SET      | Set Error Trap Function     |
;;;
;/////////////////////////////////////////////////////////////////////////////////////////

And here is the attached lisp:

SAG6.zip

Link to comment
Share on other sites

Thanks for that buzz.

After this job done i made another program for square diffusers. It works as i want it to be without any errors. Only thing is that i want to add an "error trap" to it. Inspite of going through notes & tutorials i m not able to get it done all by myself. Can you just add an error trap to my this program without changing it. That would give me an better idea.

 

; SUPPLY AIR DIFFUSER

;

;Lisp to draw SUPPLY DIFFUSER of the size desired by the user

;Type sad, you will have to click on the insertion point.

;later just type in the size you want

;eg: Type 300 for a sad of (300x300) size.

;It will also draw a branch & boot top which needs to be edited by the user.

(defun c:sad(/ r1 r2 r3 r4 l1 ha hao hat ha1 hao1 hat1 ha2 hao2 hat2

ha3 hao3 hat3 insp sz p1 p2 p3 p4 p5 p6 p7 p8 ce osm clyr insp

l1 l2 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pin pin1 pp1 pp2 pp3 pp4 pp5 pp6

pp7 pin2 ppp1 ppp2 ppp3 ppp4 ppp5 ppp6 ppp7 pin3 pppp1 pppp2

pppp3 pppp4 pppp5 pppp6 pppp7 bnm)

(princ "\n Program by Vivian Carvalho")

(setq insp(getpoint "\nSpecify the insertion point : ")

sz(getdist "\nSpecify the size : ")

p1(polar insp 0.7853979 (sqrt (+(*(/ sz 2)(/ sz 2))(*(/ sz 2)(/ sz 2)))))

p2(polar insp 3.926989 (sqrt (+(*(/ sz 2)(/ sz 2))(*(/ sz 2)(/ sz 2)))))

p3(polar p1 3.926989 (* 0.189 sz))

p4(polar p2 0.7853979 (* 0.189 sz))

p5(polar p3 3.926989 (* 0.189 sz))

p6(polar p4 0.7853979 (* 0.189 sz))

p7(polar p5 3.926989 (* 0.189 sz))

p8(polar p6 0.7853979 (* 0.189 sz))

ce(getvar "cmdecho")

osm(getvar "osmode")

clyr(getvar "clayer"))

(if (null(tblsearch "layer" "DIFFUSERS"))

(command "layer" "n" "DIFFUSERS" "color" "72" "DIFFUSERS" "")

(princ))

(command "osmode" 0)

(command "cmdecho" 0)

(command "rectang" p1 p2)

(setq r1(entlast))

(command "rectang" p3 p4)

(setq r2(entlast))

(command "rectang" p5 p6)

(setq r3(entlast))

(command "rectang" p7 p8)

(setq r4(entlast))

(command "line" p1 p2"")

(setq l1(entlast))

(command "mirror" l1"" insp (polar insp 1.570796 (/ sz 2)) "n")

(setq l2(entlast)

pin(polar insp 1.570796 (+(/ sz 2)(* sz 0.22))) ;top arrow

pt1(polar pin 3.141592 (* sz 0.06))

pt2(polar pin 0.0 (* sz 0.06))

pt3(polar pt1 1.570796 (* sz 0.416))

pt4(polar pt2 1.570796 (* sz 0.416))

pt5(polar pt3 3.141592 (* sz 0.1))

pt6(polar pt4 0.0 (* sz 0.1))

pt7(polar pin 1.570796 (* sz 0.717)))

(command "pline" pin "w" "0" "0" pt2 pt4 pt6 pt7 "c")

(setq ha(entlast))

(command "pline" pin "w" "0" "0" pt1 pt3 pt5 pt7 "")

(setq hao(entlast))

(command "-hatch" "p" "s" "s" ha "" "")

(setq hat(entlast)

pin1(polar insp 0.0 (+(/ sz 2)(* sz 0.22))) ;right arrow

pp1(polar pin1 1.570796 (* sz 0.06))

pp2(polar pin1 4.712387 (* sz 0.06))

pp3(polar pp1 0.0 (* sz 0.416))

pp4(polar pp2 0.0 (* sz 0.416))

pp5(polar pp3 1.570796 (* sz 0.1))

pp6(polar pp4 4.712387 (* sz 0.1))

pp7(polar pin1 0.0 (* sz 0.717)))

(command "pline" pin1 "w" "0" "0" pp2 pp4 pp6 pp7 "c")

(setq ha1(entlast))

(command "pline" pin1 "w" "0" "0" pp1 pp3 pp5 pp7 "")

(setq hao1(entlast))

(command "-hatch" "p" "s" "s" ha1 "" "")

(setq hat1(entlast)

pin2(polar insp 4.712387 (+(/ sz 2)(* sz 0.22))) ;down arrow

ppp1(polar pin2 0.0 (* sz 0.06))

ppp2(polar pin2 3.141592 (* sz 0.06))

ppp3(polar ppp1 4.712387 (* sz 0.416))

ppp4(polar ppp2 4.712387 (* sz 0.416))

ppp5(polar ppp3 0.0 (* sz 0.1))

ppp6(polar ppp4 3.141592 (* sz 0.1))

ppp7(polar pin2 4.712387 (* sz 0.717)))

(command "pline" pin2 "w" "0" "0" ppp2 ppp4 ppp6 ppp7 "c")

(setq ha2(entlast))

(command "pline" pin2 "w" "0" "0" ppp1 ppp3 ppp5 ppp7 "")

(setq hao2(entlast))

(command "-hatch" "p" "s" "s" ha2 "" "")

(setq hat2(entlast)

pin3(polar insp 3.141592 (+(/ sz 2)(* sz 0.22))) ;left arrow

pppp1(polar pin3 4.712387 (* sz 0.06))

pppp2(polar pin3 1.570796 (* sz 0.06))

pppp3(polar pppp1 3.141592 (* sz 0.416))

pppp4(polar pppp2 3.141592 (* sz 0.416))

pppp5(polar pppp3 4.712387 (* sz 0.1))

pppp6(polar pppp4 1.570796 (* sz 0.1))

pppp7(polar pin3 3.141592 (* sz 0.717)))

(command "pline" pin3 "w" "0" "0" pppp2 pppp4 pppp6 pppp7 "c")

(setq ha3(entlast))

(command "pline" pin3 "w" "0" "0" pppp1 pppp3 pppp5 pppp7 "")

(setq hao3(entlast))

(command "-hatch" "p" "s" "s" ha3 "" "")

(setq hat3(entlast))

(command "change" r1 r2 r3 r4 l1 l2 ha hao hat ha1 hao1 hat1

ha2 hao2 hat2 ha3 hao3 hat3"" "p" "la" "DIFFUSERS" "")

(setq bnm (strcat "Sdiff" (rtos sz 2 0)))

(if (null(tblsearch "block" bnm))

(progn (command "block" bnm insp "previous" "")

(command "insert" bnm insp "1" "1" "0"))

(progn (command "erase" "previous" "")

(command "insert" bnm insp "1" "1" "0")))

(if (null(tblsearch "layer" "DUCTING"))

(command "layer" "n" "DUCTING" "c" "magenta" "DUCTING" "")

(princ))

(setq ct1(polar p1 1.570796 150)

c1(polar ct1 0.0 25)

c2(polar c1 3.141592 (+ sz 50))

c3(polar c1 4.712387 (- (* sz 3) 100))

c4(polar c2 4.712387 (* sz 3))

c5(polar c4 0.0 (+ sz 150))

c6(polar c2 4.712387 (- (* sz 3) 100)))

(command "pline" c4 "w" "0" "0" c2 c1 c3 c5 "")

(setq bpl(entlast))

(command "line" c3 c6 "")

(setq bt(entlast))

(command "change" bpl bt "" "p" "la" "DUCTING" "")

(command "clayer" clyr)

(command "osmode" osm)

(command "cmdecho" ce)

(princ))

Link to comment
Share on other sites

Hey Viv,

 

Great to see you are still at it.

I will have something for you later, I have a doctors appointment this morning, So when I get back, I get started on this for you.

 

I noticed when I run your program shown here, It seems to have a bracket out of place or something else.

 

Command: _appload SAD.lsp successfully loaded.

Command: ; error: malformed list on input

 

I will look at this of course first.

Please check your posted code and make sure everything is OK.

 

I contact you later in the day.

 

The Buzzard

 

Also please note, I am working on some sort of an HVAC duct program with many options. I am taking my time on this one to make sure I get this right. I am doing this as blocks with attributes to get a material take-off. I will be posting some time in the distant future.

 

Keep an eye out for it.

Link to comment
Share on other sites

I noticed a Kool Face in your code above.

 

When posting codes please use the advanced options and paste the code between code brackets using the # icon.

 

That should avoid these problems.

 

In any event, This is what I am getting now:

 

Command:

SAD

Program by Vivian Carvalho

Specify the insertion point :

Specify the size : 300

layer

Current layer: "0"

Enter an option

[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:

n

Enter name list for new layer(s): DIFFUSERS Enter an option

[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:

color

New color [Truecolor/COlorbook] : 72

Enter name list of layer(s) for color 72 : DIFFUSERS Enter an option

[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:

Command: Unknown command "-HATCH". Press F1 for help.

Unknown command "P". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "-HATCH". Press F1 for help.

Unknown command "P". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "-HATCH". Press F1 for help.

Unknown command "P". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "-HATCH". Press F1 for help.

Unknown command "P". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "S". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Unknown command "SAD". Press F1 for help.

Command: Z

ZOOM

Specify corner of window, enter a scale factor (nX or nXP), or

[All/Center/Dynamic/Extents/Previous/Scale/Window] : A

Regenerating model.

 

 

Seem like a problem at the moment with the hatch command.

Link to comment
Share on other sites

I also noticed you are saving your user settings after you get user input.

 

Saving your user settings is the first thing you should before anything else. I showed you how to do this on the previous SAG codes.

 

Also use setvar instead of command when setting your user settings. Not real important, However it seems proper.

Link to comment
Share on other sites

Hi Buzz thanks for that quick reply.

 

Is something wrong with your health ? Get well soon.

 

Yes i m still at it & will be till i get very busy with work.

 

The program runs perfectly with me

may be that i & even you dint notice (command "rectang" p7 p8)

in the program. That normally occurs in copy & paste.

Buzz at first only add the error trap to my program without changing the original one. That will give me an idea for the other programs i m working on & i know later on you will come up with an better one.

I will be waiting for your reply.

 

Take care

 

Thanks & regards

Vivian

Link to comment
Share on other sites

Hi Buzz thanks for that quick reply.

 

Is something wrong with your health ? Get well soon.

 

Yes i m still at it & will be till i get very busy with work.

 

The program runs perfectly with me

may be that i & even you dint notice (command "rectang" p7 p8)

in the program. That normally occurs in copy & paste.

Buzz at first only add the error trap to my program without changing the original one. That will give me an idea for the other programs i m working on & i know later on you will come up with an better one. I will be waiting for your reply.

 

Take care

 

Thanks & regards

Vivian

 

I see a doctor on a regular basis as I am a disabled veteran, But I am OK. As I mention before about your user settings, I would need to fix this first in order to use the error trap. Also the hatch problem may stem from the fact that I may not have the correct hatch or something else is required to work with this program. That may be why I am getting these errors.

Link to comment
Share on other sites

Viv,

 

Here the deal, I just got back and looked at the code. As I mentioned before there was a hatch error showing up and several times for the same block.

 

You are using -hatch when there is no such command. I changed this to -bhatch at all four locations in the code and it works well now. I will also need to fix the user settings before I can proceed with an error trap. I hope you do not mind if I do this. If this is going to be a problem, Please let me know.

Link to comment
Share on other sites

Here is the program with the error trap and the hatch command modified to -bhatch. Please note I had to move your user settings to the begining of the code.

 

Please keep in mind that the error trap is one of the last things you should put into your code. If you are still making modifications and you make an error in the coding, The error will not show up on the command prompt.

 

I also want to point out you have the insert call after you block your objects which is not needed. Once you block all your objects, Your block reference will be in the drawing. I cannot help but notice you are trying to put everything into one function. Please try to use additional functions in the code to ease up on the congestion.

 

 

Good Luck again with your coding and your block looks great!

 

; SUPPLY AIR DIFFUSER
;
;Lisp to draw SUPPLY DIFFUSER of the size desired by the user
;Type sad, you will have to click on the insertion point.
;later just type in the size you want
;eg: Type 300 for a sad of (300x300) size.
;It will also draw a branch & boot top which needs to be edited by the user.
(defun c:sad (/     r1   r2 r3    r4    l1   ha hao   hat
      ha1   hao1  hat1 ha2   hao2  hat2  ha3 hao3  hat3
      insp  sz   p1 p2    p3    p4   p5 p6    p7
      p8    ce   osm clyr  insp  l1   l2 pt1   pt2
      pt3   pt4   pt5 pt6   pt7   pin   pin1 pp1   pp2
      pp3   pp4   pp5 pp6   pp7   pin2  ppp1 ppp2  ppp3
      ppp4  ppp5  ppp6 ppp7  pin3  pppp1 pppp2 pppp3 pppp4
      pppp5 pppp6 pppp7 bnm)
 (princ "\n Program by Vivian Carvalho")
 (setq orm  (getvar "orthomode"))
 (setq ce   (getvar "cmdecho"))
 (setq osm  (getvar "osmode"))
 (setq clyr (getvar "clayer"))
 (setq terr *error*)
 (setq *error* SAD_SET)
 (setvar "osmode" osm)
 (setq insp (getpoint "\nSpecify the insertion point : ")
sz   (getdist "\nSpecify the size : ")
p1   (polar insp 0.7853979 (sqrt (+ (* (/ sz 2) (/ sz 2)) (* (/ sz 2) (/ sz 2)))))
p2   (polar insp 3.926989  (sqrt (+ (* (/ sz 2) (/ sz 2)) (* (/ sz 2) (/ sz 2)))))
p3   (polar p1 3.926989 (* 0.189 sz))
p4   (polar p2 0.7853979 (* 0.189 sz))
p5   (polar p3 3.926989 (* 0.189 sz))
p6   (polar p4 0.7853979 (* 0.189 sz))
p7   (polar p5 3.926989 (* 0.189 sz))
p8   (polar p6 0.7853979 (* 0.189 sz)))
 (if (null (tblsearch "layer" "DIFFUSERS"))
   (command "layer" "n" "DIFFUSERS" "color" "72" "DIFFUSERS" "")
   (princ))
 (setvar "osmode" 0)
 (setvar "cmdecho" 0)
 (command "rectang" p1 p2)
 (setq r1 (entlast))
 (command "rectang" p3 p4)
 (setq r2 (entlast))
 (command "rectang" p5 p6)
 (setq r3 (entlast))
 (command "rectang" p7 p8)
 (setq r4 (entlast))
 (command "line" p1 p2 "")
 (setq l1 (entlast))
 (command "mirror" l1 "" insp (polar insp 1.570796 (/ sz 2)) "n")
 (setq l2  (entlast)
pin (polar insp 1.570796 (+ (/ sz 2) (* sz 0.22))) ;top arrow
pt1 (polar pin 3.141592 (* sz 0.06))
pt2 (polar pin 0.0 (* sz 0.06))
pt3 (polar pt1 1.570796 (* sz 0.416))
pt4 (polar pt2 1.570796 (* sz 0.416))
pt5 (polar pt3 3.141592 (* sz 0.1))
pt6 (polar pt4 0.0 (* sz 0.1))
pt7 (polar pin 1.570796 (* sz 0.717)))
 (command "pline" pin "w" "0" "0" pt2 pt4 pt6 pt7 "c")
 (setq ha (entlast))
 (command "pline" pin "w" "0" "0" pt1 pt3 pt5 pt7 "")
 (setq hao (entlast))
 (command "-bhatch" "p" "s" "s" ha "" "")
 (setq hat  (entlast)
pin1 (polar insp 0.0 (+ (/ sz 2) (* sz 0.22))) ;right arrow
pp1  (polar pin1 1.570796 (* sz 0.06))
pp2  (polar pin1 4.712387 (* sz 0.06))
pp3  (polar pp1 0.0 (* sz 0.416))
pp4  (polar pp2 0.0 (* sz 0.416))
pp5  (polar pp3 1.570796 (* sz 0.1))
pp6  (polar pp4 4.712387 (* sz 0.1))
pp7  (polar pin1 0.0 (* sz 0.717)))
 (command "pline" pin1 "w" "0" "0" pp2 pp4 pp6 pp7 "c")
 (setq ha1 (entlast))
 (command "pline" pin1 "w" "0" "0" pp1 pp3 pp5 pp7 "")
 (setq hao1 (entlast))
 (command "-bhatch" "p" "s" "s" ha1 "" "")
 (setq hat1 (entlast)
pin2 (polar insp 4.712387 (+ (/ sz 2) (* sz 0.22))) ;down arrow
ppp1 (polar pin2 0.0 (* sz 0.06))
ppp2 (polar pin2 3.141592 (* sz 0.06))
ppp3 (polar ppp1 4.712387 (* sz 0.416))
ppp4 (polar ppp2 4.712387 (* sz 0.416))
ppp5 (polar ppp3 0.0 (* sz 0.1))
ppp6 (polar ppp4 3.141592 (* sz 0.1))
ppp7 (polar pin2 4.712387 (* sz 0.717)))
 (command "pline" pin2 "w" "0" "0" ppp2 ppp4 ppp6 ppp7 "c")
 (setq ha2 (entlast))
 (command "pline" pin2 "w" "0" "0" ppp1 ppp3 ppp5 ppp7 "")
 (setq hao2 (entlast))
 (command "-bhatch" "p" "s" "s" ha2 "" "")
 (setq hat2  (entlast)
pin3  (polar insp 3.141592 (+ (/ sz 2) (* sz 0.22))) ;left arrow
pppp1 (polar pin3 4.712387 (* sz 0.06))
pppp2 (polar pin3 1.570796 (* sz 0.06))
pppp3 (polar pppp1 3.141592 (* sz 0.416))
pppp4 (polar pppp2 3.141592 (* sz 0.416))
pppp5 (polar pppp3 4.712387 (* sz 0.1))
pppp6 (polar pppp4 1.570796 (* sz 0.1))
pppp7 (polar pin3 3.141592 (* sz 0.717)))
 (command "pline" pin3 "w" "0" "0" pppp2 pppp4 pppp6 pppp7 "c")
 (setq ha3 (entlast))
 (command "pline" pin3 "w" "0" "0" pppp1 pppp3 pppp5 pppp7 "")
 (setq hao3 (entlast))
 (command "-bhatch" "p" "s" "s" ha3 "" "")
 (setq hat3 (entlast))
 (command "change"  r1 r2     r3     r4     l1     l2
   ha   hao  hat ha1    hao1   hat1   ha2    hao2
   hat2   ha3  hao3 hat3   ""     "p"    "la"   "DIFFUSERS" "")
 (setq bnm (strcat "Sdiff" (rtos sz 2 0)))
 (if (null (tblsearch "block" bnm))
   (progn (command "block" bnm insp "previous" "")
   (command "insert" bnm insp "1" "1" "0"))
   (progn (command "erase" "previous" "")
   (command "insert" bnm insp "1" "1" "0")))
 (if (null (tblsearch "layer" "DUCTING"))
   (command "layer" "n" "DUCTING" "c" "magenta" "DUCTING" "")
   (princ))
 (setq ct1 (polar p1 1.570796 150)
c1  (polar ct1 0.0 25)
c2  (polar c1 3.141592 (+ sz 50))
c3  (polar c1 4.712387 (- (* sz 3) 100))
c4  (polar c2 4.712387 (* sz 3))
c5  (polar c4 0.0 (+ sz 150))
c6  (polar c2 4.712387 (- (* sz 3) 100)))
 (command "pline" c4 "w" "0" "0" c2 c1 c3 c5 "")
 (setq bpl (entlast))
 (command "line" c3 c6 "")
 (setq bt (entlast))
 (command "change" bpl bt "" "p" "la" "DUCTING" "")
 (setq *error* terr)
 (setvar "clayer" clyr)
 (setvar "orthomode" orm)
 (setvar "osmode" osm)
 (setvar "cmdecho" ce)
 (princ  "\nProgram Has Restored The User Settings.")
 (princ)
)
(defun SAD_SET (ERRORMSG)
 (command nil nil nil)
 (if (not (member ERRORMSG '("console break" "Function Cancelled")))
   (princ (strcat "\nError:" ERRORMSG)))
 (setvar "cmdecho"   ce)
 (setvar "orthomode" orm)
 (setvar "osmode"    osm)
 (setvar "clayer"    clyr)
 (princ  "\nAttention! An Error Has Occurred!")
 (princ  "\nProgram Now Restoring The User Settings.")
 (terpri)
 (setq *error* terr)
 (princ)
)

Link to comment
Share on other sites

Viv,

 

This is why I changed the -HATCH command call you had and why the program had the error I posted.

 

When I typed -HATCH at the command prompt, This is what I get:

 

Command: -hatch

Unknown command "-HATCH". Press F1 for help.

 

If I type HATCH, This is what I get:

 

Command: HATCH

Enter a pattern name or [?/Solid/User defined] :

 

When -BHATCH is typed, This is what I get:

 

Command: -BHATCH

Current hatch pattern: ANSI31

Specify internal point or [Properties/Select/Remove islands/Advanced]:

 

In your code you had something like this in four locations calling for a hatch:

 

(command "-hatch" "p" "s" "s" ha "" "")

 

Notice the "p" which would be properties. This is not in HATCH command and there is no such command as -HATCH, So I had to change this to -BHATCH.

 

This is what you posted.

; SUPPLY AIR DIFFUSER
;
;Lisp to draw SUPPLY DIFFUSER of the size desired by the user
;Type sad, you will have to click on the insertion point.
;later just type in the size you want
;eg: Type 300 for a sad of (300x300) size.
;It will also draw a branch & boot top which needs to be edited by the user.
(defun c:sad(/ r1 r2 r3 r4 l1 ha hao hat ha1 hao1 hat1 ha2 hao2 hat2
ha3 hao3 hat3 insp sz p1 p2 p3 p4 p5 p6 p7 p8 ce osm clyr insp
l1 l2 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pin pin1 pp1 pp2 pp3 pp4 pp5 pp6
pp7 pin2 ppp1 ppp2 ppp3 ppp4 ppp5 ppp6 ppp7 pin3 pppp1 pppp2
pppp3 pppp4 pppp5 pppp6 pppp7 bnm)
(princ "\n Program by Vivian Carvalho")
(setq insp(getpoint "\nSpecify the insertion point : ")
sz(getdist "\nSpecify the size : ")
p1(polar insp 0.7853979 (sqrt (+(*(/ sz 2)(/ sz 2))(*(/ sz 2)(/ sz 2)))))
p2(polar insp 3.926989 (sqrt (+(*(/ sz 2)(/ sz 2))(*(/ sz 2)(/ sz 2)))))
p3(polar p1 3.926989 (* 0.189 sz))
p4(polar p2 0.7853979 (* 0.189 sz))
p5(polar p3 3.926989 (* 0.189 sz))
p6(polar p4 0.7853979 (* 0.189 sz))
p7(polar p5 3.926989 (* 0.189 sz))
p8(polar p6 0.7853979 (* 0.189 sz))
ce(getvar "cmdecho")
osm(getvar "osmode")
clyr(getvar "clayer"))
(if (null(tblsearch "layer" "DIFFUSERS"))
(command "layer" "n" "DIFFUSERS" "color" "72" "DIFFUSERS" "")
(princ))
(command "osmode" 0)
(command "cmdecho" 0)
(command "rectang" p1 p2)
(setq r1(entlast))
(command "rectang" p3 p4)
(setq r2(entlast))
(command "rectang" p5 p6)
(setq r3(entlast))
(command "rectang" p7 p
(setq r4(entlast))
(command "line" p1 p2"")
(setq l1(entlast))
(command "mirror" l1"" insp (polar insp 1.570796 (/ sz 2)) "n")
(setq l2(entlast)
pin(polar insp 1.570796 (+(/ sz 2)(* sz 0.22))) ;top arrow
pt1(polar pin 3.141592 (* sz 0.06))
pt2(polar pin 0.0 (* sz 0.06))
pt3(polar pt1 1.570796 (* sz 0.416))
pt4(polar pt2 1.570796 (* sz 0.416))
pt5(polar pt3 3.141592 (* sz 0.1))
pt6(polar pt4 0.0 (* sz 0.1))
pt7(polar pin 1.570796 (* sz 0.717)))
(command "pline" pin "w" "0" "0" pt2 pt4 pt6 pt7 "c")
(setq ha(entlast))
(command "pline" pin "w" "0" "0" pt1 pt3 pt5 pt7 "")
(setq hao(entlast))
(command "-hatch" "p" "s" "s" ha "" "")
(setq hat(entlast)
pin1(polar insp 0.0 (+(/ sz 2)(* sz 0.22))) ;right arrow
pp1(polar pin1 1.570796 (* sz 0.06))
pp2(polar pin1 4.712387 (* sz 0.06))
pp3(polar pp1 0.0 (* sz 0.416))
pp4(polar pp2 0.0 (* sz 0.416))
pp5(polar pp3 1.570796 (* sz 0.1))
pp6(polar pp4 4.712387 (* sz 0.1))
pp7(polar pin1 0.0 (* sz 0.717)))
(command "pline" pin1 "w" "0" "0" pp2 pp4 pp6 pp7 "c")
(setq ha1(entlast))
(command "pline" pin1 "w" "0" "0" pp1 pp3 pp5 pp7 "")
(setq hao1(entlast))
(command "-hatch" "p" "s" "s" ha1 "" "")
(setq hat1(entlast)
pin2(polar insp 4.712387 (+(/ sz 2)(* sz 0.22))) ;down arrow
ppp1(polar pin2 0.0 (* sz 0.06))
ppp2(polar pin2 3.141592 (* sz 0.06))
ppp3(polar ppp1 4.712387 (* sz 0.416))
ppp4(polar ppp2 4.712387 (* sz 0.416))
ppp5(polar ppp3 0.0 (* sz 0.1))
ppp6(polar ppp4 3.141592 (* sz 0.1))
ppp7(polar pin2 4.712387 (* sz 0.717)))
(command "pline" pin2 "w" "0" "0" ppp2 ppp4 ppp6 ppp7 "c")
(setq ha2(entlast))
(command "pline" pin2 "w" "0" "0" ppp1 ppp3 ppp5 ppp7 "")
(setq hao2(entlast))
(command "-hatch" "p" "s" "s" ha2 "" "")
(setq hat2(entlast)
pin3(polar insp 3.141592 (+(/ sz 2)(* sz 0.22))) ;left arrow
pppp1(polar pin3 4.712387 (* sz 0.06))
pppp2(polar pin3 1.570796 (* sz 0.06))
pppp3(polar pppp1 3.141592 (* sz 0.416))
pppp4(polar pppp2 3.141592 (* sz 0.416))
pppp5(polar pppp3 4.712387 (* sz 0.1))
pppp6(polar pppp4 1.570796 (* sz 0.1))
pppp7(polar pin3 3.141592 (* sz 0.717)))
(command "pline" pin3 "w" "0" "0" pppp2 pppp4 pppp6 pppp7 "c")
(setq ha3(entlast))
(command "pline" pin3 "w" "0" "0" pppp1 pppp3 pppp5 pppp7 "")
(setq hao3(entlast))
(command "-hatch" "p" "s" "s" ha3 "" "")
(setq hat3(entlast))
(command "change" r1 r2 r3 r4 l1 l2 ha hao hat ha1 hao1 hat1
ha2 hao2 hat2 ha3 hao3 hat3"" "p" "la" "DIFFUSERS" "")
(setq bnm (strcat "Sdiff" (rtos sz 2 0)))
(if (null(tblsearch "block" bnm))
(progn (command "block" bnm insp "previous" "")
(command "insert" bnm insp "1" "1" "0"))
(progn (command "erase" "previous" "")
(command "insert" bnm insp "1" "1" "0")))
(if (null(tblsearch "layer" "DUCTING"))
(command "layer" "n" "DUCTING" "c" "magenta" "DUCTING" "")
(princ))
(setq ct1(polar p1 1.570796 150)
c1(polar ct1 0.0 25)
c2(polar c1 3.141592 (+ sz 50))
c3(polar c1 4.712387 (- (* sz 3) 100))
c4(polar c2 4.712387 (* sz 3))
c5(polar c4 0.0 (+ sz 150))
c6(polar c2 4.712387 (- (* sz 3) 100)))
(command "pline" c4 "w" "0" "0" c2 c1 c3 c5 "")
(setq bpl(entlast))
(command "line" c3 c6 "")
(setq bt(entlast))
(command "change" bpl bt "" "p" "la" "DUCTING" "")
(command "clayer" clyr)
(command "osmode" osm)
(command "cmdecho" ce)
(princ))

 

It would stand to reason the program would error from this. I cannot see how this would work on your system.

 

In any case the program is up and running.

I just wanted to clarify this with you.

 

Also when posting codes in the future, Please use the code brackets in the advanced options indicated by the # icon. This will also save some headaches.

Link to comment
Share on other sites

Viv,

 

In addition to having a formal error trap function as the one I placed in your code, This is only good when the user hits escape in mid operation of using the program.

 

There are other forms of error trapping that involve avoiding errors that come with normal use of the program.

 

For example: Default settings.

Your program does not have these, So if you were to hit enter instead of providing user input, Your program will then error unless you provide a default setting.

 

The layers are another issue.

With the function I provided you on the SAG6.lsp and others, I provided you with a layer function that takes into account that if a particular layer is to be set and it happens to be frozen at the time of program use, The function will then thaw it and set it.

 

Using initget also provides a way to accept only certain types of input.

 

I could go on and on with all the things you can place in your programs to make them more industrial strength, But you need to experiment more to see what can be improved in your codes.

 

Myself just like you I am also learning as well. I put together a program for you to see some fine features so that you will have a model to work from. It does not pay to rush your coding for the sake of just getting the program good enough to get by.

 

If your programs are all going to work in a similar way, You need to get the first one right so you do not repeat the same mistakes over & over.

 

I know as well as you do that programming is not an easy task, But when it is done correctly the payoffs are great. Sure we need to get our programs done fast so we can use them as soon as possible, But that can only come with time, patience and persistence.

 

Just something you should consider.

 

I do not mean to be critical of your coding, But if you ask for ways to improve it and they are provided to you, Then please use them. I want to see you take your coding above where its been, You have the potential to do it and the help here to get you there.

Link to comment
Share on other sites

Hi Buzz

The -hatch command was & is working fine on our systems , dont know how it does not in yours. Anyways thanks for the corrections . I take them all positively. This program is also doing great for me.

 

Regards

Vivian

Link to comment
Share on other sites

Hi Buzz

The -hatch command was & is working fine on our systems , dont know how it does not in yours. Anyways thanks for the corrections . I take them all positively. This program is also doing great for me.

 

Regards

Vivian

 

Hi Viv,

 

Please forgive me on this one, I looked further into this and found in AutoCAD 2009 that in fact there is a -HATCH. When I tested your program, I did it with AutoCAD 2004 which does not have a -HATCH which is why I got the error. I guess I spoke too soon. I should have looking deeper into this from the beginning.

 

It would be a good idea to note in your header that this program will not work in earlier versions of acad. If you keep the command as -BHATCH you should not have problem with these versions, But that is upto you.

 

It would have been difficullt to install the error trap while the program showed an error. The error in question would have been covered up by this function. I forgot you are using a newer version of AutoCAD.

 

In any case it still is a good idea to review the other error trapping methods I have mentioned to make your program more sound just the same.

 

Once again I am sorry for doubting you.

And Good Luck with your coding.

The Buzzard

Link to comment
Share on other sites

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...