Jump to content

Please help with this block insert routine...


Recommended Posts

Posted

Hey guys,

 

Ive got this simple routine which I would like to improve (hopefully with your help).

 

The routine is quite straight forward – it will insert a hole note (block) with leader at a location determined by the user. The routine will prompt the user for three points as well as hole quantity and diameter.

 

The only problem im having with the routine at the moment is… I have a block for the holenote which is only ideal for hole notes pointing in one direction. I will like to add a condition to the routine which would insert a block depending on the points picked by the user. Please see the attached sketch for a hopefully clearer explanation. The first image is how the routine runs at the moment – which is fine in this direction. The second is how it runs at the moment – in the opposite direction. The third image is how I would like it to run in the opposite direction.

 

So… I was thinking/hoping that some would please be able to help me tweak the routine to allow a different block to be inserted, depending on if the X value of the third point is greater or less than the X value of the second point.

 

Another thing I would like to set is if the quantity of holes is only 1… the STRCAT function would compile with "/%%C"AHdia" HOLE" (rather than HOLES).

 

(Defun c:AH ()
(SETVAR "ORTHOMODE" 0)
(SETQ AHSCALE (GETVAR "DIMSCALE")) 
(command "-layer" "set" "1dl" "")
(SETQ AHPT1 (GETPOINT))
(SETQ AHPT2 (GETPOINT AHPT1))
(command "QLEADER" AHPT1 AHPT2 NIL)
(SETVAR "ORTHOMODE" 1)
(SETQ AHPT3 (GETPOINT AHPT2))
(SETQ AHQTY (getstring "\nEnter Quantity of Holes : " XX))
(SETQ AHdia (getstring "\nEnter Diameter of Holes : " XX))
(setq ahnote (strcat AHQTY"/%%C"AHdia" HOLES"))
(COMMAND "INSERT" "holenote" AHPT2 AHSCALE "" "" ahnote "")
(princ)
)

 

Thanks a lot for any help.

 

HoleNote1.jpg

Posted

??

 

(defun c:AH (/ *error* om cm p1 p2 p3 q d)

 (defun *error* (msg)
   (redraw)
   (and om (setvar 'ORTHOMODE om))
   (and cm (setvar 'CMDECHO cm))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (setq om (getvar 'ORTHOMODE)
       cm (getvar 'CMDECHO)
 )
 (setvar 'ORTHOMODE 0)
 (setvar 'CMDECHO 0)

 (if (and (setq p1 (getpoint "\nSpecify first point: "))
          (setq p2 (getpoint p1 "\nSpecify next point: "))
          (progn (grdraw p1 p2 256) (setvar 'ORTHOMODE 1))
          (setq p3 (getpoint p2 "\nSpecify landing point: "))
          (progn (grdraw p2 p3 256) (initget 6) (setq q (getint "\nSpecify quantity of holes: ")))
          (progn (initget 6) (setq d (getint "\nSpecify diameter of holes: ")))
     )
   (command "_.leader"
            "_non"
            p1
            "_non"
            p2
            "_non"
            p3
            "_A"
            (strcat (itoa q) "/%%C" (itoa d) " HOLE")
            ""
   )
 )

 (*error* nil)
 (princ)
)

Posted

1 you need to work out which quadrant you are in then the leader would be drawn in the correct way just check the angle between ahpt1 and ahpt2 compare 0-90 90-180 180-270 270-360 but in radians do a condition COND with the 4 dififerent ways to draw it. Probably do some polar calcs based on first point for a correct drawn 2nd point but use 2nd pick point as a approx guess.

 

2 Holes pretty easy change strcat and use a if statement if hole more than 1 then holes=holes else holes = hole

 

(if (< ahqty 1) 
(setq ahnote (strcat AHQTY"/%%C"AHdia" HOLE"))
(setq ahnote (strcat AHQTY"/%%C"AHdia" HOLES"))
)

Posted
(defun c:AH (/ *error* om cm p1 p2 p3 q d)

 (defun *error* (msg)
   (redraw)
   (and om (setvar 'ORTHOMODE om))
   (and cm (setvar 'CMDECHO cm))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (setq om (getvar 'ORTHOMODE)
       cm (getvar 'CMDECHO)
 )
 (setvar 'ORTHOMODE 0)
 (setvar 'CMDECHO 0)

 (if (and (setq p1 (getpoint "\nSpecify first point: "))
          (setq p2 (getpoint p1 "\nSpecify next point: "))
          (progn (grdraw p1 p2 256) (setvar 'ORTHOMODE 1))
          (setq p3 (getpoint p2 "\nSpecify landing point: "))
          (progn (grdraw p2 p3 256) (initget 6) (setq q (getint "\nSpecify quantity of holes: ")))
          (progn (initget 6) (setq d (getint "\nSpecify diameter of holes: ")))
     )
   (command "_.leader"
            "_non"
            p1
            "_non"
            p2
            "_non"
            p3
            "_A"
            (strcat (itoa q)
                    "/%%C"
                    (itoa d)
                    (if (> q 1)
                      " HOLES"
                      " HOLE"
                    )
            )
            ""
   )
 )

 (*error* nil)
 (princ)
)

  • 2 years later...
Posted

Oh crap,

 

I was just reading through some of my old posts looking for a thread I may or may not have started... and realised I never responded to this one.

 

I'm sorry for being so rude guys. Thanks a lot for all your help. It is this routine which I use to create our hole notes, and it has been great.

 

Thanks again and sorry again.

Posted
Oh crap,

 

I was just reading through some of my old posts looking for a thread I may or may not have started... and realised I never responded to this one.

 

I'm sorry for being so rude guys. Thanks a lot for all your help. It is this routine which I use to create our hole notes, and it has been great.

 

Thanks again and sorry again.

 

lol. Better late than never. :)

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...