Jump to content

Lisp for 3D dimensions


mrjagsr744

Recommended Posts

Can someone help me create a LISP routine for dimensioning 3D piping?

Here is what I am trying to accomplish,

1. set the OSNAP to "node"

2. set the UCS origin using 3 points

3. create a linear dimension based on the UCS settings

4. after dimension is drawn go back to step 1

5. when no more dimensions are needed, I would like the UCS to be set back to "World",

 

I don't mind the osnap being left set to "node". Also I would like this routine to work when I am in PS if possible.

I was able to do it using a macro, and I want to convert the macro into a lisp routine that can do what I listed above.

This is the macro routine I have.

^C^C_.ucsicon _or _.ucs 3 \\\_.dimlinear

Link to comment
Share on other sites

here is what I have been able to write so far (still learning) but it stops as soon as the 3 point UCS command is done.

What is preventing it from continuing to the dimlinear command?

 

(defun c:3d-dim ()
(setq osm-old(getvar "osmode"))
(setvar "osmode" 
(setq ort-old (getvar "orthomode"))
(setvar "orthomode" 1)
(setq spt (getpoint "\nSpecify UCS location and direction"))  
(command "ucs" "3" spt)
(command "_.dimlinear" pause pause pause)
(setvar "osmode" 
(setvar "osmode" osm-old)
(setvar "orthomode" ort-old)
(command "ucs" "world")
)
(princ)

Link to comment
Share on other sites

(defun c:3d-dim (/ *error* ico-old ort-old osm-old pto ptx pty)

 (defun *error* (msg)
   (setvar "osmode" osm-old)
   (setvar "orthomode" ort-old)
   (setvar "ucsicon" ico-old)
   (command "ucs" "world")
   (if (not (member msg '("Function cancelled" "quit / exit abort")))
     (princ (strcat "\nError: " msg))
   )
   (princ)
 )

 (setq osm-old (getvar "osmode"))
 (setq ort-old (getvar "orthomode"))
 (setq ico-old (getvar "ucsicon"))
 (setvar "orthomode" 1)
 (setvar "osmode" 
 (while (and (setq pto (getpoint "\nSpecify new origin point: "))
             (setq ptx (getpoint pto "\nSpecify point on positive portion of X-axis: "))
             (setq pty (getpoint pto
                                 "\nSpecify point on positive-Y portion of the UCS XY plane : "
                       )
             )
        )
   (command "ucs" "3" pto ptx pty)
   (setvar "ucsicon" 2)
   (command "_.dimlinear")
   (while (> (getvar 'cmdactive) 0)
     (command pause)
   )
 )
 (setvar "osmode" osm-old)
 (setvar "orthomode" ort-old)
 (setvar "ucsicon" ico-old)
 (command "ucs" "world")
 (princ)
)

Henrique

Edited by hmsilva
Link to comment
Share on other sites

I am not that experienced in VLISP but I thought I would give this a try. It seems to work. Just hit Enter instead of specifying a location for the next UCS origin to terminate the program and reset the UCS to world.

 

(defun c:3d-dim	()
 (setq osm-old (getvar "osmode"))
 (setvar "osmode" 
 (setq ort-old (getvar "orthomode"))
 (setvar "orthomode" 1)
 (setq spt1 (getpoint "\nSpecify UCS origin"))
 (setq spt2 (getpoint "\nSpecify UCS 2nd point"))
 (setq spt3 (getpoint "\nSpecify UCS 3rd point"))
 (command "ucs" "3" spt1 spt2 spt3)
 (while spt1
   (setq d1 (getpoint "\n1st dim point"))
   (setq d2 (getpoint "\n2nd dim point"))
   (setq d3 (getpoint "\ndim location"))
   (command "dimlinear" d1 d2 d3)
   (setq spt1 nil)
   (setq spt1 (getpoint "\nSpecify UCS origin"))
   (if	spt1
     (progn
(setq spt2 (getpoint "\nSpecify UCS 2nd point"))
(setq spt3 (getpoint "\nSpecify UCS 3rd point"))
(command "ucs" "3" spt1 spt2 spt3)
     )
   )
 )
 (princ "\nAll done!")
 (setvar "osmode" osm-old)
 (setvar "orthomode" ort-old)
 (command "ucs" "world")
)
(princ)

3d-dim.LSP

Link to comment
Share on other sites

That's pretty good Irm, what do I have to add so the ucsicon is shown graphically and the user is able to view on the screen how the ucs is being set before dimensioning?

see this video I made from using the macro.https://www.youtube.com/watch?v=su9eP3UBuT4

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...