| Author |
Message |
Jason Piercey
Guest
|
Posted:
Wed Jan 12, 2005 9:07 pm Post subject:
Re: AddLightweightPolyline and UCS |
|
|
Thanks James!
Didn't realize that the TRANSing in test2
was taking 2d points and returning 3d points.
I swear I was using 2d points to start with <g>
--
Autodesk Discussion Group Facilitator
"James Allen" <JamesA~AA~mwengrs~DD~com> wrote in message
news:41e5471f$1_3@newsprd01...
| Quote: | Hi Jason,
AddLightweightPolyline expects 2D points. Add this line before the append
in test2:
(setq lst (mapcar '(lambda (a) (reverse (cdr (reverse a)))) lst))
Depending on your application, you may also want to be sure your current
ucs
z axis is aligned with the saved view's direction before any trans calls.
If they are not, your lwpolyline will be added in the wrong plane.
James
"Jason Piercey" <Jason AT atreng DOT com> wrote in message
news:41e2e5b1_3@newsprd01...
Still not sure what I am missing here but...
Using the attached sample drawing where the
boundary of the named view is the bounding
box of the circle shown.
Test1 works
Test2 does not
; function to create a list of points representing
; the outline of a box based on the center point,
; width and height of the box.
; Arguments:
; [center] - list, 2d point
; [width] - integer or real, width of outline
; [height] - integer or real, height of outline
; returns: list of points
(defun getCornersFromCenter (center width height)
(setq height (/ height 2.0))
(setq width (/ width 2.0))
(list
(mapcar '+ center (list (- width) (- height)))
(mapcar '+ center (list width (- height)))
(mapcar '+ center (list width height))
(mapcar '+ center (list (- width) height))
)
)
; Jon flemming
(defun UCS->OCS (pt)
(trans pt 1 (trans '(0.0 0.0 1.0) 1 0 t)) )
(defun c:test1 (/ document object lst)
(setq document (vla-get-activedocument (vlax-get-acad-object)))
(setq object (vla-item (vla-get-views document) "test"))
(setq
lst
(getCornersFromCenter
(vlax-get object 'center); center is DCS
(vlax-get object 'width)
(vlax-get object 'height))
)
(setq lst (mapcar '(lambda (p) (trans p 0 1)) lst))
(command ".pline") (mapcar 'command lst) (command "c")
(princ)
)
(defun c:test2 (/ document object lst)
(setq document (vla-get-activedocument (vlax-get-acad-object)))
(setq object (vla-item (vla-get-views document) "test"))
(setq
lst
(getCornersFromCenter
(vlax-get object 'center); center is DCS
(vlax-get object 'width)
(vlax-get object 'height))
)
(setq lst (mapcar '(lambda (p) (trans p 0 1)) lst))
(setq lst (mapcar 'ucs->ocs lst))
(setq lst (apply 'append lst))
(setq
object
(vlax-invoke
(vla-get-modelspace document)
'AddLightweightPolyline
lst
)
)
(vla-put-closed object :vlax-true)
(princ)
)
--
Autodesk Discussion Group Facilitator
|
|
|
| Back to top |
|
 |
Jason Piercey
Guest
|
Posted:
Wed Jan 12, 2005 10:25 pm Post subject:
Re: AddLightweightPolyline and UCS |
|
|
On a side note, I would imagine that this would be
a slightly more sensible approach to dropping the
z values from a list of 3d points.
(mapcar '(lambda (p) (list (car p)(cadr p))) lst))
Although, I have used the double reverse in the past.
--
Autodesk Discussion Group Facilitator
"James Allen" <JamesA~AA~mwengrs~DD~com> wrote in message
news:41e5471f$1_3@newsprd01...
| Quote: | Hi Jason,
AddLightweightPolyline expects 2D points. Add this line before the append
in test2:
(setq lst (mapcar '(lambda (a) (reverse (cdr (reverse a)))) lst)) |
|
|
| Back to top |
|
 |
James Allen
Guest
|
Posted:
Wed Jan 12, 2005 11:23 pm Post subject:
Re: AddLightweightPolyline and UCS |
|
|
Thanks. Funny, that's actually what I started with and then changed it...
I've been struggling lately with vague memories of efficiency discussions on
various list manipulations (rev cdr rev to remove last element; [rev] cons
vs append to build, nth vs c[a/d]r to access, etc.). But I can't seem to
come up with the right search to find them. Maybe someone would be willing
to review...
James
"Jason Piercey" <Jason AT atreng DOT com> wrote in message
news:41e55d6b$1_1@newsprd01...
| Quote: | On a side note, I would imagine that this would be
a slightly more sensible approach to dropping the
z values from a list of 3d points.
(mapcar '(lambda (p) (list (car p)(cadr p))) lst))
Although, I have used the double reverse in the past.
--
Autodesk Discussion Group Facilitator
"James Allen" <JamesA~AA~mwengrs~DD~com> wrote in message
news:41e5471f$1_3@newsprd01...
Hi Jason,
AddLightweightPolyline expects 2D points. Add this line before the
append
in test2:
(setq lst (mapcar '(lambda (a) (reverse (cdr (reverse a)))) lst))
|
|
|
| Back to top |
|
 |
Jason Piercey
Guest
|
Posted:
Thu Jan 13, 2005 12:06 am Post subject:
Re: AddLightweightPolyline and UCS |
|
|
I know from discussion here that APPEND
is the slow beast. I tend to use CONS and
a REVERSE more than anything.
While I'm not sure about the speed differential
between CAR/CADR vs. the double REVERSE
I can't imagine that reversing a list twice would
be faster than simply extracting the elements that
are needed.
--
Autodesk Discussion Group Facilitator
"James Allen" <JamesA~AA~mwengrs~DD~com> wrote in message
news:41e56b0e$1_2@newsprd01...
| Quote: | Thanks. Funny, that's actually what I started with and then changed it...
I've been struggling lately with vague memories of efficiency discussions
on
various list manipulations (rev cdr rev to remove last element; [rev] cons
vs append to build, nth vs c[a/d]r to access, etc.). But I can't seem to
come up with the right search to find them. Maybe someone would be
willing
to review...
James |
|
|
| Back to top |
|
 |
|
|
|
|