Jump to content

Recommended Posts

  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    22

  • Lt Dan's legs

    17

  • Lee Mac

    12

  • REID7800

    8

Top Posters In This Topic

Posted Images

Posted

Okay new problem but for a similar lisp. I'm trying to get this box to stretch. I'm trying to modify the lisp you provided (alan) to stretch the box to width and length

(defun c:[b]Single[/b] (/ blockname p1 p2)
 ;; Insert and stretch "[color=black][b]singlebox[/b][/color]" block (required)
 ;; Alan J. Thompson, 05.05.10
 (vl-load-com)
 (setq blockname "[b]singlebox[/b]")
 (if (and (or (tblsearch "block" blockname)
              (findfile (strcat blockname ".dwg"))
              (alert (strcat blockname " cannot be found!"))
          )
          (setq p1 (getpoint "\nSpecify block insertion point: "))
          (setq p2 (getpoint p1 "\[b]nSpecify Box width:[/b] "))
     )
   ((lambda (block)
      (foreach x (vlax-invoke block 'GetDynamicBlockProperties)
        (and (eq (vla-get-propertyname x) "[b]width[/b]")
             (vla-put-value
               x
               ((lambda (dist / num)
                  (cond
                    ((>= 1. (/ dist 46.)) (setq num 46.))
                    ((< 1. (setq num (/ dist 46.))) (setq num (* 46. (1+ (fix num)))))
                  )
                  num
                )
                 (distance p1 p2)
               )
             )
        )
      )
      (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block))))
    )
     (vla-insertblock
       (if
         (or (eq acmodelspace
                 (vla-get-activespace
                   (cond (*AcadDoc*)
                         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                   )
                 )
             )
             (eq :vlax-true (vla-get-mspace *AcadDoc*))
         )
          (vla-get-modelspace *AcadDoc*)
          (vla-get-paperspace *AcadDoc*)
       )
       (vlax-3d-point (trans p1 1 0))
       blockname
       1.
       1.
       1.
       (angle (trans p1 1 0) (trans p2 1 0))
     )
   )
 )
 (princ)
)

 

I've made my changes bold. I want the second prompt to be "\nSpecify Box length: ")). I just don't know how to make it function. Also, how do I remove the 46" increments? Is it as simple as removing

((lambda (dist / num)
                  (cond
                    ((>= 1. (/ dist 46.)) (setq num 46.))
                    ((< 1. (setq num (/ dist 46.))) (setq num (* 46. (1+ (fix num)))))
                  )
                  num
                )

? I'm really trying to get a grasp on this and I appreciate all the help

Posted

I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). :)

Posted
I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). :)

 

Sorry, I'm still new to all of this. I made my changes bold but I guess its hardly noticeable

Posted
Sorry' date=' I'm still new to all of this. I made my changes bold but I guess its hardly noticeable[/quote']

 

Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. :)

Posted

Hey alan.. I've kind of figured out my problem. this is what I want my box to do but I don't know how to fix the increments

(defun c:test (/ blockname p1 p2 P3)
 (vl-load-com)
 (setq blockname "1compartment")
 (if (and (or (tblsearch "block" blockname)
              (findfile (strcat blockname ".dwg"))
              (alert (strcat blockname " cannot be found!"))
          )
          (setq p1 (getpoint "\nSpecify block insertion point: "))
          (setq p2 (getpoint p1 "\nSpecify box width: "))
          (setq p3 (getpoint p2 "\nSpecify box length: "))
     )
   ((lambda (block)
      (foreach x (vlax-invoke block 'GetDynamicBlockProperties)
        (and (eq (vla-get-propertyname x) "DISTANCE")
             (vla-put-value
               x
               ((lambda (dist / num)
                  (cond
                    ((>= 1. (/ dist 1.)) (setq num 1.))
                    ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num))))
                  )
                  num
                )
                 (distance p1 p2)
               )
             ))
         (and(eq (vla-get-propertyname x) "DISTANCE1")
             (vla-put-value
               x
               ((lambda (dist / num)
                  (cond
                    ((>= 1. (/ dist 1.)) (setq num 1.))
                    ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num))))
                  )
                  num
                )
                 (distance p2 p3)
               )
             )
        )
      )
      (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block))))
    )
     (vla-insertblock
       (if
         (or (eq acmodelspace
                 (vla-get-activespace
                   (cond (*AcadDoc*)
                         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                   )
                 )
             )
             (eq :vlax-true (vla-get-mspace *AcadDoc*))
         )
          (vla-get-modelspace *AcadDoc*)
          (vla-get-paperspace *AcadDoc*)
       )
       (vlax-3d-point (trans p1 1 0))
       blockname
       1.
       1.
       1.
       (angle (trans p1 1 0) (trans p2 1 0))
     )
   )
 )
 (princ)
)

 

I'm trying to get it to go by the prompt and not by clicking on the screen. distance would go 0º and distance1 would go 90º

Posted
Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. :)

 

 

 

 

The increments will be based on whatever you have set in the block. That's where I originally got the 46. from.

Posted
The increments will be based on whatever you have set in the block. That's where I originally got the 46. from.

 

This is a different block. I'm just changing the code to make it work for this Dyn blk. This block is a box with dimensions. I want it to be able to stretch in increments of 1/8"

Posted
This is a different block. I'm just changing the code to make it work for this Dyn blk. This block is a box with dimensions. I want it to be able to stretch in increments of 1/8"

 

I know, but the Long Wall block's increments were based on 46. You just have to base it on whatever number you used when creating the block (1/8" in this case).

Posted

okay so how do I put that in the code? Everytime I try to change this to a smaller number than one it gives me an input error

 

((lambda (dist / num)
                  (cond
                    ((>= 1. (/ dist 1.)) (setq num 1.))
                    ((< 1. (setq num (/ dist 1.))) (setq num (* 1. (fix num))))
                  )
                  num
                )
                 (distance p2 p3)
               )

Posted

(/ dist 1.)

 

The 1. should be your increment (as I had 46. there).

Posted
(/ dist 1.)

 

The 1. should be your increment (as I had 46. there).

 

 

When I change it to (/ dist .125) it comes up with "; error: misplaced dot on input"

Posted
When I change it to (/ dist .125) it comes up with "; error: misplaced dot on input"

 

.125 is not a valid number. Try 0.125

Posted
Nice! thanks

Did you get it to work?

 

 

BTW' date=' please heed the following...

I'll look at it in a few. However, in the mean time, if you are going to edit code I've posted, please denote your edits (as they are not mine). :)

 

Don't sweat it. It just that you've made changes on something I submitted with my name on it, but what you've submitted is partially your work. When editing another person's work, always state where you made edits. Take credit for your work and be proud. :)
Posted

Yes it did. Sorry, I need to practice this.

Posted
Yes it did. Sorry' date=' I need to practice this.[/quote']

Good deal. Sorry I haven't had a chance to open the file and give it a look.

 

No sweat, that's why I reminded you. :)

Posted

Okay one last question and I swear I'm done with this thread! How do I take the mouse out of the equation? I know by taking the p1 out of the setq p2 & p3 it does the job but the outcome of the box size isn't the numbers I typed in on the line.

 

;; Alan J. Thompson, 05.05.10
;; parts modified by Reid B. 05.12.10
(defun c:COMP1 (/ blockname p1 p2 P3);; modified by Reid b.
 (vl-load-com)
 (setq blockname "1compartment")
 (if (and (or (tblsearch "block" blockname)
              (findfile (strcat blockname ".dwg"))
              (alert (strcat blockname " cannot be found!"))
          )
          (setq p1 (getpoint "\nSpecify block insertion point: "))
          (setq p2 (getpoint p1 "\nSpecify box width: ")) ;; modified by Reid b.
          (setq p3 (getpoint p1 "\nSpecify box length: ")) ;;by Reid b.
     )
   ((lambda (block)
      (foreach x (vlax-invoke block 'GetDynamicBlockProperties)
        (and (eq (vla-get-propertyname x) "DISTANCE")
             (vla-put-value
               x
               ((lambda (dist / num)
                  (cond
                    ((>= 0.125 (/ dist 0.125)) (setq num 0.125))
                    ((< 0.125 (setq num (/ dist 0.125))) (setq num (* 0.125 (fix num))))
                  )
                  num
                )
                 (distance p1 p2)
               )
             )) ;; modified by Reid b.
         (and(eq (vla-get-propertyname x) "DISTANCE1")
             (vla-put-value
               x
               ((lambda (dist / num)
                  (cond
                    ((>= 0.125 (/ dist 0.125)) (setq num 0.125))
                    ((< 0.125 (setq num (/ dist 0.125))) (setq num (* 0.125 (fix num))))
                  )
                  num
                )
                 (distance p1 p3)
               ) ;;by Reid b.
             )
        )
      )
      (vl-catch-all-apply (function (lambda () (vla-explode block) (vla-delete block))))
    )
     (vla-insertblock
       (if
         (or (eq acmodelspace
                 (vla-get-activespace
                   (cond (*AcadDoc*)
                         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                   )
                 )
             )
             (eq :vlax-true (vla-get-mspace *AcadDoc*))
         )
          (vla-get-modelspace *AcadDoc*)
          (vla-get-paperspace *AcadDoc*)
       )
       (vlax-3d-point (trans p1 1 0))
       blockname
       1.
       1.
       1.
       0.
       (angle (trans p1 1 0) (trans p2 1 0)) ;; modified by Reid b.
     )
   )
 )
 (princ)
)

Posted

Use GetDist in place of GetPoint for p2, p3 (some other parts of the code will need to be modified also.

Posted
Use GetDist in place of GetPoint for p2, p3 (some other parts of the code will need to be modified also.

 

There you go. Thanks Lee. :)

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