Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Progessing from angle to channel....I thought

12 REPLIES 12
Reply
Message 1 of 13
HullDrafter
793 Views, 12 Replies

Progessing from angle to channel....I thought

About a year a go Kent1Cooper provided me with a lisp program to make an angle. It came in very handy and I still use it. I have also used it as a learning tool to understand what I am trying to do with Lisp. As through natural progession, I thought I could expand upon the angle and make a channel. If I did everything correctly I would poolish the channel, but, as before I am missing something. I can't get my channel to lay out correctly.

 

(DEFUN C:channel ()
  (COMMAND "ORTHO" "OFF")
  (setq old_osmode (getvar "osmode"))
  (setvar "osmode" 0)
  (SETQ
    PT1  (GETPOINT "\nHeel of channel:")
    DT1  (GETDIST PT1 "\nLength of first leg:")
    DT2  (GETDIST PT1 "\nLength of second leg:")
    THK  (GETDIST PT1 "\nThickness:")
    ANG1 (GETDIST "\nEnd-of-leg fillet radius:")
    ANG2 (GETDIST "\nIntersection-of-legs fillet radius:")
  )     ; end setq
  (COMMAND "_.PLINE"
    PT1
           (polar PT1 0 DT1)
    (polar (getvar 'lastpoint) (/ pi 2) (- THK ANG1))
    "A"
    (strcat "@-" (rtos ANG1) "," (rtos ANG1))
    "L"
    (strcat "@-" (rtos (- DT1 THK ANG1 ANG2)) ",0")
    "A"
    (strcat "@-" (rtos ANG2) "," (rtos ANG2))
    "L"
    (strcat "@0," (rtos (- DT2 THK ANG2 ANG2)))
    "A"
    (strcat "@0" (rtos ANG2) "," (rtos ANG2))
    "L"
    (strcat "@" (rtos (- DT1 THK ANG1 ANG2)) ",0")
    "A"
    (strcat "@" (rtos ANG1) "," (rtos ANG1))
    "L"
    (polar (getvar 'lastpoint) (/ pi 2) (- THK ANG1))
           "L"
    (polar (getvar 'lastpoint) (/ pi 1) (DT1))
           "C"
  )     ; end command
  (setvar "osmode" old_osmode)
  (Command "ORTHO" "ON")
)     ; end defun
(PRINC)

 

The red line is where my problem lies. I need the line to go left and everything I try sends the line up.

The parameters for simplicity sake is 50,100,10,6,12. Think metric. I am asking Kent1Cooper or someone with as much patience as seems to show for a little assistance.

I've tried Polar command as well as Strcat using positive and negative numbers.

I have reread how to use those Lisp commands and thought I understood. Could someone help and then tell me what section I missed in the tutorials or in AFRALISP.

 

Thank you,

HD

12 REPLIES 12
Message 2 of 13
Kent1Cooper
in reply to: HullDrafter


@HullDrafter wrote:

....

(DEFUN C:channel ()
....
    (strcat "@0," (rtos (- DT2 THK ANG2 ANG2)))
....
    (polar (getvar 'lastpoint) (/ pi 1) (DT1))
....

The red line is where my problem lies.....


I think the problem is the parentheses around DT1 -- it shouldn't have them, though why it would be sending it in the wrong direction rather than giving you some kind of error message, I don't know.

While you're there, (/ pi 1) may as well be just pi.

 

Also, in the other line I left quoted above, shouldn't you subtract THK twice?  I think you need to take both flange thicknesses as well as both internal fillet radiuses off the overall depth for that inside line segment:

 

  (strcat "@0," (rtos (- DT2 THK THK ANG2 ANG2)))

 

And it may work as you have it, but the second "@0" doesn't need the 0.

 

Also, that last "L" option isn't needed -- you're already in Line mode.

 

One last thing:  I would be inclined to ask not for leg lengths [leftover from the angle routine, I assume], but channel depth and flange width, and I would ask for the depth first rather than the flange width as you have it, since that's how channels are designated [here in the US, at least].

Kent Cooper, AIA
Message 3 of 13
HullDrafter
in reply to: Kent1Cooper

You were right about the thickness, and about the questions to be asked. But, I still can't get the last line to go to the left. Even when I use pi, that particular line goes straight up the appropriate length. From this point, I am wondering if I have a sys. Variable that is not set to default, but I check units and any other variable that might change which way (0) Zero is but mine is set for default (the 3 o'clock position).

Guess I'll keep plugging away until I find what I am missing.

Thank you for the assistance.

HD

Message 4 of 13
Anonymous
in reply to: HullDrafter

I do not intend to be at all critical of this routine or the programming but do question though the methodology of making these channels so liberally. Can user just enter any values they want? Why I ask is that there are only some 30+/- standard channels in the Imperial (US) sizes and another 30 +/- in the metric we use up here in the cold north. (Canada)

I created routines for most Imperial and Metric size steel members for W, WWF, HSS, RSS, C and Angles many years ago and ultimately most of them are now blocks. The routine was much similar to the above other than users were prompted for member by actual description such as W10X40 or C12x27. This prompted the routine to read a data file end then the section was "parametrically" created. At times Osnap setting fouled things up.

Anyway, blocks are better.   

Message 5 of 13
Kent1Cooper
in reply to: HullDrafter


@HullDrafter wrote:

.... I still can't get the last line to go to the left. Even when I use pi, that particular line goes straight up the appropriate length. ....


Did you take out the "L" prior to that segment?  I just realized that not only is that not "needed" to get the Line option which you're already in, but if you're in Line mode, "L" gives you the length option instead, and that always takes the next segment in the direction the previous one was headed [a continuation in the same direction if the previous one was a line segments, or a tangent continuous of the ending direction if it was an arc segment].  So the (polar) function establishes the appropriate length, but Pline only uses the distance to the point it finds to tell it the length, and continues in the same direction it was headed in the previous segment.

Kent Cooper, AIA
Message 6 of 13
HullDrafter
in reply to: Kent1Cooper

I stand corrected, and feel a little foolish, I thought I had taken out the "L" but had left it. Lisp works, thank you for mentioning that part again.

HD

Message 7 of 13
HullDrafter
in reply to: Anonymous

As you know, some people learn and practice different things. I work with people who watch me enter two letter commands for most of my commands. Others can only use pull-downs to work various commands. When I can work the proper commands and get them into a proper LISP format, I will create the dialog box so that all they have to do is use a pull-down in the box and not enter any information. As for myself,  with the assistance of others who know how to write LISP code, I will learn to write programs to help speed up productivity and get more out of CAD than I have been getting.

Message 8 of 13
Kent1Cooper
in reply to: HullDrafter

HullDrafter wrote...

I stand corrected....I thought I had taken out the "L" but had left it. Lisp works, thank you for mentioning that part again.

 

You're welcome.  As in most problem situations, it's often a good idea to just get the "L" out of there!

Kent Cooper, AIA
Message 9 of 13
stevor
in reply to: Anonymous

Did you publish the code?

Is it still used by you?

 

S
Message 10 of 13
Anonymous
in reply to: stevor

Never "published".

Used internally over the years by 60-80 Cadders.

Yes, still works and in use.

Message 11 of 13
Anonymous
in reply to: Kent1Cooper

Took me a minuite to laugh. I didn't get it the first time.

Message 12 of 13
Anonymous
in reply to: Anonymous

A minute?

Message 13 of 13
Anonymous
in reply to: Anonymous

mhmm

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report