PDA

View Full Version : selection set manipulation/midpoints/coordinates



j_r_auden
7th Feb 2005, 04:44 pm
1. Once you have a selection set, how can you manipulate the data in the selection set. Example ->
I create a selection set that includes all AcadLines on screen.
Then I want to go through a loop that passes the line to another function.
How do I access the objects in my selection set, are they indexed ??
I have written my function to accept a "Line", but when I pass it
mysset(0) it gives me an error. Does this selection set store the actual object and I need to pass the entire object, or is it a pointer, or what ??

2. Also, I noticed that a line has the properties of startpoint and endpoint, but no midpoint. Is there an easy way to get the coordinates of the midpoint of a line or must you write you own function ??

3. How are coordinates stored in VBA. If I want to print coordinates to a MsgBox, how do I do this. Also, if I wanted to pass some coordinates to a function, what type of argument do i pass. Variant ??

Thanks for the help !!!!!!!

fuccaro
8th Feb 2005, 07:59 am
1.

(defun c:test()
(setq selset (ssget "X" (list '(0 . "LINE"))))
(setq i 0)
(repeat (sslength selset)
(setq a_line (ssname selset i)
i (1+ i))
; here you will do something with a_line
(setq l_data (entget a_line)
l_data (subst (cons 8 "0") (assoc 8 l_data) l_data))
; for example: move it to Layer "0"
(entmod l_data)
)
(princ)
)

2. You must write the code your self. The coords of the mid point are the average of the ends coords.

hendie
8th Feb 2005, 09:29 am
in VBA coordinates are stored as a Variant (three-element array of doubles)
Once you have the startpoint you retrieve the values by using

msgbox _
"X = " & Myendpoint(0) & vbcrlf & _
"Y = " & Myendpoint(1) & vbcrlf & _
"Z = " & Myendpoint(2) & vbcrlf, vbokonly, "Coords example"

You have to write your own midpoint function. Get the length and the angle, then calculate the new point from that.
But beware if the user has changed the UCS, you will need to translate the coordinates depending upon what you are doing with them.

Once you have the selection set, you loop through the set and apply whatever function you want to them


For each LineObj in MyLines

do all your stuff here

Next LineObj

j_r_auden
8th Feb 2005, 03:08 pm
thanks for the help. I've got it working now. :D