Author Topic: UCS effect on lsp's  (Read 13777 times)

0 Members and 1 Guest are viewing this topic.

PHX cadie

  • Water Moccasin
  • Posts: 1902
UCS effect on lsp's
« on: October 11, 2006, 07:43:08 PM »
Not sure if I should even ask this, not having an understanding of any of the languages, lsp or any.
Currently during mostly Mech stuff we have 3 lsp routines that are very handy, endpipe, (that yin-yang thing), cuttube (the figure 8 symbol) and centerline. All these routines work if the UCS is to the world, but coming from a Civil firm I don't do everything to the world UCS.

Is there a fix to get lsp's to function with a user (?) UCS
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

dan19936

  • Guest
Re: UCS effect on lsp's
« Reply #1 on: October 11, 2006, 08:04:14 PM »
A quick answer is that when in lisp, mixing point selection via (command "autocadcommand" ...) which uses local user UCS coordinates and entget which uses world WCS coordinates will get you in trouble. Use the trans function to convert between WCS & UCS. For example:


;;; quick COPY text or insert from insertion point
(defun-q c:CS1  ( / ss1 e1 ins1)
  (BCV-ERROR-INIT (list (list "cmdecho" 0 "osnapcoord" 0 "osmode" (getvar "osmode")) T))
  (SETV "osmode" 1088)   ;turn on insertion snap for text pick
  (if (and (setq ss1 (ssget "+.:S:E:L" '((0 . "INSERT,*TEXT"))))   ;select one insert on unlocked layer
           (setq e1  (ssname ss1 0))            ;get entity name
           (setq ins1 (trans (cdr (assoc 10 (entget e1))) 0 1))      ;get insertion point
      ) ;and
    (progn
      (command "copy" "si" e1 ins1)
      (RSETV "osmode") ;reset to normal snaps for final pick
      (BCV_CMDACTIVE nil)
    ) ;progn
  ) ;if
  (BCV-ERROR-RESTORE)
)


the trans function converts the entget point from WCS 0 to UCS 1

Dan

sinc

  • Guest
Re: UCS effect on lsp's
« Reply #2 on: October 11, 2006, 08:10:43 PM »
All these routines work if the UCS is to the world, but coming from a Civil firm I don't do everything to the world UCS.

Yowsa!  If you don't use the world UCS, you get incorrect bearings.  I take it you do nothing with bearings?

I work in a Civil firm, and we basically use nothing BUT the world UCS...

Quote
Is there a fix to get lsp's to function with a user (?) UCS

You should be able to get any Lisp to function any way you want it to, it's just a matter of making the right adjustments to the code...

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: UCS effect on lsp's
« Reply #3 on: October 12, 2006, 12:31:09 AM »
Sinc:
 Lets say on the overall site plan a Bldg has a slight rotation, compared to North to the top of the sheet. On the Bldg plan I'd use WCSROT to get the walls square with that sheet and UCS, n, ob to do a section or elevation.  If I do a bearing/dist or ID its on the WCS.
Hope I didn't scare ya

Dan:
 Sorry I forgot to mention. I tried the 05 tutorials for lisp and had to start the 2nd chapter resorting to the backup examples because my work from the first chapter failed  :oops:  :-D
It may take awhile but I need to study on your response.

Thanks for all the replies!
I'll be back!

I'm not the sharpest knife in the kitchen, but I'm not the dullest either
« Last Edit: October 12, 2006, 12:46:27 AM by PHX cadie »
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: UCS effect on lsp's
« Reply #4 on: October 12, 2006, 01:56:28 AM »
Hi,

Quote
(setq ins1 (trans (cdr (assoc 10 (entget e1))) 0 1))      ;get insertion point

This will work only if UCS XY plane is parallel to WCS XY plane.
Insertion point coordinates of a block or text are defined in OCS (Object Coordinates System).

The following codes will work whatever the current UCS and the entity OCS :

Code: [Select]
(setq ins1 (trans (cdr (assoc 10 (entget e1))) e1 1))or
Code: [Select]
(setq ins1 (trans (cdr (assoc 10 (entget e1))) (cdr (assoc 210 (entget e1))) 1))
A 2D entiy's OCS is calculated by AutoCAD regarding its extrusion direction (210 DXF code or Normal property) using an "arbitrary axis algorithm" (see "Advanced DXF concepts" in the DXF section of the Developper's guide).
You can calculate an entity's OCS using this code :

Code: [Select]
;;; OCS Calculates the OCS of a 2D entity (text, block, circle, arc, lwpolyline, hatch ...)
;;; Argument : zdir, a single unit vector as returned by 210 DXF code
(defun sco (zdir / xdir)
  (if (and (< (abs (car zdir)) 0.015625)
   (< (abs (cadr zdir)) 0.015625)
      )
    (setq xdir (vunit (v^v '(0 1 0) zdir)))
    (setq xdir (vunit (v^v '(0 0 1) zdir)))
  )
  (list xdir (vunit (v^v zdir xdir)) zdir)
)

;;; VUNIT Returns the vector's single unit vector
;;; Argument : v, a vector
(defun vunit (v / l)
  (if (/= 0 (setq l (sqrt (apply '+ (mapcar '* v v)))))
    (mapcar '(lambda (x) (/ x l)) v)
  )
)

;;; V^V Returns the cross product of two vecors
;;; (the normal vector of the plane defined by v1 v2)
;;; Argument : v1 v2, two non-colinear vectors
(defun v^v (v1 v2)
  (if (inters '(0 0 0) v1 '(0 0 0) v2)
    (list (- (* (cadr v1) (caddr v2)) (* (caddr v1) (cadr v2)))
  (- (* (caddr v1) (car v2)) (* (car v1) (caddr v2)))
  (- (* (car v1) (cadr v2)) (* (cadr v1) (car v2)))
    )
    '(0.0 0.0 0.0)
  )
)

« Last Edit: November 14, 2006, 01:50:58 AM by gile »
Speaking English as a French Frog

sinc

  • Guest
Re: UCS effect on lsp's
« Reply #5 on: October 12, 2006, 11:47:02 AM »
Sinc:
 Lets say on the overall site plan a Bldg has a slight rotation, compared to North to the top of the sheet. On the Bldg plan I'd use WCSROT to get the walls square with that sheet and UCS, n, ob to do a section or elevation.  If I do a bearing/dist or ID its on the WCS.
Hope I didn't scare ya


What is WCSROT?  Are you talking about Drawing Orientation in Land Desktop, or is this something else?  I get no hits on it in the help.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: UCS effect on lsp's
« Reply #6 on: October 12, 2006, 12:44:03 PM »
The ROT is rotation, so it is rotating the WCS to 2 picked points. I believe it resets the origin too.
Now how is that diff (pros/cons) than using a object UCS I'm not sure. Have to think about that one.
Don't know about Land, I've been using vanilla CAD 2000 and up, but you're right, I didn't see anything under help either.
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Dinosaur

  • Guest
Re: UCS effect on lsp's
« Reply #7 on: October 12, 2006, 12:46:07 PM »
Could it be a lisp routine that is set to autoload?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: UCS effect on lsp's
« Reply #8 on: October 12, 2006, 01:24:04 PM »
« Last Edit: October 12, 2006, 09:19:13 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: UCS effect on lsp's
« Reply #9 on: October 12, 2006, 02:49:22 PM »
 :lmao:
Ahh Maan I lost amy avatar  :cry:
 :lmao:
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

Dinosaur

  • Guest
Re: UCS effect on lsp's
« Reply #10 on: October 12, 2006, 02:57:32 PM »
:lmao:
Ahh Maan I lost amy avatar  :cry:
 :lmao:
Must have been those CIA spooks in the bear suits . . . shoulda' left well enough alone. :evil: :lmao:

sinc

  • Guest
Re: UCS effect on lsp's
« Reply #11 on: October 12, 2006, 08:30:57 PM »
I could not find WCSROT but did find this:


Don't see WCSROT in the Express Tools Help, and typing WCSROT in LDD 2007 yields "Unknown coimmand".

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: UCS effect on lsp's
« Reply #12 on: October 12, 2006, 11:01:16 PM »
OMG. I'm very sorry, WCSROT is a lisp  :oops: Not even sure where it came from anymore. I can post the code if you wish
Glad Dino knows what I'm doing even though I don't, including spelling.   ( %^&* Bear suits! )


But I'm still not understanding if there is a fix for these routines at work
« Last Edit: October 12, 2006, 11:17:41 PM by PHX cadie »
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

sinc

  • Guest
Re: UCS effect on lsp's
« Reply #13 on: October 13, 2006, 01:38:34 AM »
OMG. I'm very sorry, WCSROT is a lisp  :oops: Not even sure where it came from anymore. I can post the code if you wish
Glad Dino knows what I'm doing even though I don't, including spelling.   ( %^&* Bear suits! )

I must admit, I'm curious about what it does.  I had not realized that it was possible to change the WCS; I always just assumed the WCS was the WCS.

Quote
But I'm still not understanding if there is a fix for these routines at work

Can you post any of them?  Undoubtedly, they can be "fixed", but without knowing how the routines work right now, it is difficult to give any more specific information than has already been offered.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: UCS effect on lsp's
« Reply #14 on: October 13, 2006, 07:47:54 AM »
I think sinc is correct. I'll bet the routine is miss named.
Here a a few routines like that:
http://www.theswamp.org/index.php?topic=3714.msg44665#msg44665
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

PHX cadie

  • Water Moccasin
  • Posts: 1902
Re: UCS effect on lsp's
« Reply #15 on: October 13, 2006, 01:34:15 PM »
Heres the WCS one. I need to ask the boss who owns/permission for the work ones
« Last Edit: October 13, 2006, 06:51:54 PM by PHX cadie »
Acad 2013 and XM
Back when High Tech meant you had an adjustable triangle

sinc

  • Guest
Re: UCS effect on lsp's
« Reply #16 on: October 13, 2006, 06:34:06 PM »
Heres the WCS one. I need to ask the boss who owns/permission for the work ones

Yep, looks like that basically only creates a rotated view.

It wouldn't work at all with Land Desktop, since Land Desktop bearings are determined by the UCS, sort of.  Actually, it's a bit more convoluted than that, and Land Desktop really does not work at all right if the user is not in WCS.  It is caused by a whole series of coding errors in Land Desktop - slightly different code would not have the issues.  But Land Desktop has always been like that, and it won't be fixed at this point.

In reality, LDD uses the Northing/Easting grid to label bearings.  The N/E grid is not the same thing as the WCS or a UCS, but it is similar.  And because the Land Desktop labelling routines are not written correctly, they get confused if you use a UCS.

None of this applies unless you are using Land Desktop, though.