Author Topic: Control Units  (Read 2172 times)

0 Members and 1 Guest are viewing this topic.

Chris

  • Swamp Rat
  • Posts: 548
Control Units
« on: August 07, 2008, 10:10:24 AM »
Does anyone know if there is a way to control when units switch from decimal to scientific notation.  I have a point that is returning 1.25933e+007 as a real, but I would like it to return 12593312.xxxx
I cant use an integer as it doesnt work with the program I have, I need it to be a real.
any help is appreciated
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #1 on: August 07, 2008, 10:32:01 AM »
Code: [Select]
Command: (rtos 1.25933e+007 2 )
"12593300.00000"
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #2 on: August 07, 2008, 10:35:29 AM »
Code: [Select]
Command: (rtos 1.25933e+007 2 )
"12593300.00000"
how do I convert the string back to a real number for calculation?
Alan, you helped me write the program back in 06, to determine the station and offset of various points in a drawing relative to a center line.  I am finding that if the drawing is at very high coordinates, more blocks are filtered out than should be. and my hunch is it has too do with the scientific notation.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #3 on: August 07, 2008, 10:51:27 AM »
Code: [Select]
Command: (distof "12593300.00000")
1.25933e+007

Command: (atof "12593300.00000")
1.25933e+007

If the filter was on a string then Yes, but if a number it should not matter. (theory not tested )  8-)
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #4 on: August 07, 2008, 11:01:58 AM »
I am at a loss as to why it doesnt work at high coordinates.  If I move the points closer to 0 the program will catch all the points for their station/offset.  I even tried changing the ucs, but then I get an error:
Pick the beginning of the alignment.
Error - Not the beginning of the alignment.
Maybe I should look at that, set it up so for large coordinates, we create a temporary ucs, run the offset program, then reset to the world ucs.  but I need the beginning of the polyline to be recognized.  any clue why if you change the coordinate system, the beginning of a 2d polyline is no longer recognized as the beginning?

is there a way to grab user coordinates instead of world coordinates for the polyline?
Code: [Select]
(defun get_startpoint (ename / pt selpt)
  (while
    (not
      (and
        (setq
          pt (osnap (getpoint "\nPick the beginning of the alignment.")
                    "_end"
             )
        )
        (setq selpt (vlax-curve-getclosestpointto ename pt))[color=red]; when I check this, it maintains the wcs coordinates instead of the adjusted user cordinates[/color]
        (and selpt (listp selpt))
        (< (distance pt selpt) 0.1)
      )
    )
     (prompt "\nError - Not the beginning of the alignment.")
  )
  selpt
)
it helps when you read the help, I have found this is normal behavior for this command, is there anyway to use ucs?
« Last Edit: August 07, 2008, 11:15:33 AM by Chris »
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #5 on: August 07, 2008, 11:44:53 AM »
I don't think the routine was set up to deal with UCS, only WCS.
Note that vlax-curve functions must get WCS & return WCS
so try this:
Code: [Select]
(defun get_startpoint (ename / pt selpt)
  (while
    (not
      (and
        (setq
          pt (osnap (getpoint "\nPick the beginning of the alignment.")
                    "_end"
             )
        )
        (setq selpt (trans (vlax-curve-getclosestpointto ename (trans pt 1 0)) 0 1))
        (and selpt (listp selpt))
        (< (distance pt selpt) 0.1)
      )
    )
     (prompt "\nError - Not the beginning of the alignment.")
  )
  selpt
)
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #6 on: August 07, 2008, 11:49:18 AM »
after looking at the routine more closely for the entire program, vlax-curve functions are spread thorugout.  maybe a betterway to do it is at the beginning, specifiy an undo point, ask the user to specify a point, thaw,unlock,turn on all layers, and move all objects in the drawing using that point as a base point to 0,0, run the program and then undo back to the undo point
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #7 on: August 07, 2008, 11:53:38 AM »
Send me the latest version of the routine so I can take a quick look see.
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #8 on: August 07, 2008, 11:59:06 AM »
i assumed same email you had last year.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #9 on: August 07, 2008, 12:18:09 PM »
Yes I got the file, Thanks.

When you say UCS, do you mean that the drawing is rotated or moved from the WCS?
How does it differ from WCS?
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.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #10 on: August 07, 2008, 12:24:37 PM »
yes, the coordinate file is not rotated, just 0,0,0 is moved to an arbitrary point closer to the drawing, so I dont have the large numbers.

I think that I may be on to something with the grab everything and move it closer to 0,0. With an undo point, you dont have to worry about saving layers or anything like that, for any error trapping, you just undo to the undo point.  When you undo, AutoCAD doesnt delete a block that was created, it just removes the memory of creating the block from the current session of AutoCAD.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #11 on: August 07, 2008, 08:51:06 PM »
Chris,
The vlax-curve function will not work that far from the origin as you suspected.
Example:
Code: [Select]
_2$ (rtos (car (vlax-curve-getclosestpointto pline pt2d))2 16)
"12593312.24488756"
_2$ (vlax-curve-getdistatpoint pline (vlax-curve-getclosestpointto pline pt2d))
nil
_2$ (vlax-curve-getparamatpoint pline (vlax-curve-getclosestpointto pline pt2d))
nil

Although the vlax-curve-getclosestpointto will return a point on the pline the vlax-curve-getdistatpoint
does not recognise that point as being on the pline. I have not found a work-around for that problem.
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.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Control Units
« Reply #12 on: August 08, 2008, 03:09:40 AM »
i tried (vlax-curve-getdistatpoint pline (vlax-curve-getclosestpointto pline pt2d)) as far as "1374116801.128235"
it works just fine in map 2005.

Chris

  • Swamp Rat
  • Posts: 548
Re: Control Units
« Reply #13 on: August 08, 2008, 07:42:10 AM »
well, here is the solution that I finally decided to use:
Code: [Select]
(if (or (> (car (getvar "target")) 50000.0) (> (cadr (getvar "target")) 50000.0))
    (progn
      (setq basepointtouse (getpoint "\nThis drawing has large coordinates, please select an arbitrary base point\n"))
      (command "zoom" "c" "0,0" "")
      (command "layer" "Thaw" "*" "On" "*" "unlock" "*" "")
      (setq allobjectsindrawing (ssget "_X"))
      (command "move" allobjectsindrawing "" basepointtouse "0,0")
      (command "layerp")
      )
    )
I added an undo mark at the beginning of the program and set the error handler to undo back to the undo mark if the program is interrupted, or upon completion of the program.  Basically, the added code asks the user for a new base point if the target of their current view is greater than 50,000, then moves everything in the drawing, using that new point as the base point to 0,0.  then after the program has run, it runs undo back to the created mark and completes the program.
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Control Units
« Reply #14 on: August 08, 2008, 10:14:41 AM »
Here is an alternative but relies on the origin being altered.
Code: [Select]
;;  moves all objects in current space from UCS origin to WCS origin
(if (>(distance (getvar "ucsorg") '(0 0 0))50000.0)
    (progn
      (prompt "\nThis drawing has large coordinates, moving all objects\n"))
      (command "zoom" "c" "0,0" "")
      (command "layer" "Thaw" "*" "On" "*" "unlock" "*" "")
      (setq allobjectsindrawing (ssget "_X" (cons 410 (getvar "ctab"))))
      (command "move" allobjectsindrawing "" "0,0" (trans '(0 0 0) 1 0))
      (command "layerp")
      (setq allobjectsindrawing nil)
    )
)
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.