Author Topic: trying to write my first lisp and i need a bit of help  (Read 24018 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #60 on: July 28, 2005, 11:04:49 AM »
Quote from: MP
Suggestion: After the dxf coding techniques are explored parallel functionality using activex techniques should be discussed.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #61 on: July 28, 2005, 11:09:24 AM »
whatever you think is the right way but i must warn you it doesn't take much to ovewhelm me at this stage so k.i.s.s. definitely applies here  :?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #62 on: July 28, 2005, 11:10:55 AM »
We've been there Dan; I'm no rocket surgeon.

:lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #63 on: July 28, 2005, 11:18:52 AM »
so... what should i look at?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #64 on: July 28, 2005, 11:21:44 AM »
Stay with the dxf stuff Daron is laying out for you for now. Once you get to the "aha" stage then we'll show you how to do the same thing using activex.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #65 on: July 28, 2005, 11:24:20 AM »
yeah but he said to look into angle and polar but i'm not sure what he means. look where?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
trying to write my first lisp and i need a bit of help
« Reply #66 on: July 28, 2005, 11:34:21 AM »
Ya gotta learn to use the help available, that's an absolute must.

Quote from: AutoLISP Reference <Angle>
Returns an angle in radians of a line defined by two endpoints

(angle pt1 pt2)

Arguments

pt1 - An endpoint.
pt2 - An endpoint.

Return Values

An angle, in radians.

The angle is measured from the X axis of the current construction plane, in radians, with angles increasing in the counterclockwise direction. If 3D points are supplied, they are projected onto the current construction plane.

Quote from: AutoLISP Reference <Polar>
Returns the UCS 3D point at a specified angle and distance from a point

(polar pt ang dist)

Arguments

pt - A 2D or 3D point.

ang - An angle expressed in radians relative to the world X axis. Angles increase in the counterclockwise direction, independent of the current construction plane.

dist - Distance from the specified pt.

Return Values

A 2D or 3D point, depending on the type of point specified by pt.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #67 on: July 28, 2005, 11:34:28 AM »
In help under AutoLisp Reference. "A" for angle and "P" for polar. You'll find a whole new world in that reference.

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #68 on: July 28, 2005, 11:39:28 AM »
Thanks MP. Dan, I want you to find what MP posted for you. If you can find the dxf info, I'm sure you can find the ALisp References. Now, explain angle. What is its return value? What will that return value do for you? Can it be used in polar? If so, does it need to be converted to human readable degrees for polar?

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #69 on: July 28, 2005, 11:50:53 AM »
Quote
not sure why we need 10, 13, and 14 but i'll trust ya
10 and 14? Here's an exercise: In acad, run rotate. Select a dimension and on a node (where you think code14 might be) spin that baby around kinda not too fast. Notice how the angle of the whole dim object is constantly changing.

You will undoubtedly have dimensions at different angles, even if they are only ever horizontal and vertical. Regardless, using GC10 and GC14 we will always have a dimension defined angle to go from. The reason we'll need GC13 is because we need to know which direction we're going to have to get our midpoint from: 0, 90, 180 or 270 from the angle of GC10 and GC14. If you don't use GC13, your text could end up the distance of the dimtext and GC10, the opposite direction.

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #70 on: July 28, 2005, 12:16:50 PM »
aha ok now that you mention it it would be nice to be able to move the vertical text as well if i have to stretch the height. so the angle tells the angle between 2 endpoints. the polar species the point to which we want to move our text based on the angle and point we already have aquired. am i close here?

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #71 on: July 28, 2005, 12:47:00 PM »
Not sure what you mean by "species". I'll assume a typo, but I can't figure out what word should be there. Angle does tell the distance between two POINTS. Let's leave the word ENDpoints out of it though, since angle can give you the angle between any two given coordinates. They don't have to even be attached to an object and literally, the coordinates we're playing with here aren't attached to the object. In fact, coordinates are never attached to an object, though an object might be attached to a coordinate. Even when using reactors, you're still adjusting to coordinates.

As far as polar goes, you are close, but I know too well that polar can be more complicated than you realize. What polar is going to do is take a starting point an angle and a distance and return a coordinate from the supplied point, the distance supplied by the angle supplied. If we plug in (polar code10 (angle code10 code14) 5000.0) we'll get a coordinate point 5000 units along coordinates code10 and code14. That's not what we're looking for is it? Are you familiar mathematically with how to get an angle like 90 degrees?

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #72 on: July 28, 2005, 01:05:21 PM »
a typo yes i meant that to be specifies but got ahead of myself  :oops: i think i follow you about polar but the last question i don't entirely understand, no?

ELOQUINTET

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #73 on: July 28, 2005, 01:21:01 PM »
i am listening to lynn allens live meeting of getting the most out of 2006 as we are discussing this so bear with me

daron

  • Guest
trying to write my first lisp and i need a bit of help
« Reply #74 on: July 28, 2005, 01:27:20 PM »
Maybe this will help, maybe not.
Quote from: Cadaver
One radian is the angle of an arc created by wrapping the radius of a circle around its circumference.

The radius 'r' fits around the circumference of a circle exactly 2p times. That is why the circumference of a circle is given by:

circumference = 2(pi)r

So, how are we going to find 90 degrees from (angle code10 code14) toward code13?

This is what we should have at this point.
Code: [Select]
;;pick the text using the node as the point
;;then move the text to the midpoint of the dimension line
;;then move the text down 3-1/2
(defun c:MoveTextObject (/       txtentity     txtlist
txtassoc10    dimentity     dimlist
dimassoc10    dimassoc11    dimassoc13
dimassoc14    dimassoc42
)
     (setq txtentity  (car (entsel "\nSelect text: "))
  txtlist    (entget txtentity)
  txtassoc10 (cdr (assoc 10 txtlist))
     )
     (setq dimentity  (car (entsel "\nSelect dimension: "))
  dimlist    (entget dimentity)
  dimassoc10 (cdr (assoc 10 dimlist))
  dimassoc11 (cdr (assoc 11 dimlist))
  dimassoc13 (cdr (assoc 13 dimlist))
  dimassoc14 (cdr (assoc 14 dimlist))
  dimassoc42 (cdr (assoc 42 dimlist))
     )
     (setq dimang (angle dimassoc10 dimassoc14))
     (setq dimlen (/ dimassoc42 2.0))
)

I've added the angle to it and threw in a little something extra. You'll see that last piece there. Can you guess at its purpose? Hint: What is group code 42?