Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP questions for blocks and Hatch

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1085 Views, 4 Replies

LISP questions for blocks and Hatch

I've created a lisp program with short cut keys for blocks and hatch.  I draw roofing details for commercial roofing and will have typical slopes of 1/4" or 1/8" per foot and need this block to align to the slope of the roof.  When inserted thru the dialog box it will align but when inserted thru the short cut key it comes in at its original location? The code is as follows:

 

 

(defun c:qr (/ old_cmdecho)

  (setq old_cmdecho (getvar "cmdecho"))

  (setvar "cmdecho" 0)

  (command "insert" "horizontal QA RTS" pause 1 1 0)

  (setvar "cmdecho" old_cmdecho)

  (princ)

)

 

 

Is there a way to get this to align to the slope of the roof like it does when inserted thru the dialog box?

 

 

Second question is with the hatch.  I had it set and working where it would switch to the hatch layer and allow me to select the angle and then a single pick point.  Then switch back to the layer I was previously on.  I wanted it to allow me to select multiple areas as I have more than just one place I need Plywood.  So I added a space between the double quotes (" ") after my pause.  Now it gives me an error that says "2D point or option keyword required. Specify internal point or"  It will still allow me to go thru and pick my multiple points but will not finish out and switch back to original layer? Code is as follows:

 

 

(defun c:pw (/ la old_cmdecho)

  (setq old_cmdecho (getvar "cmdecho"))

  (setvar "cmdecho" 0)

  (setq la (getvar "clayer"))

  (command "-layer" "S" "hatch" "")

  (command "-hatch" "Properties" "dolmit" 1 pause pause " ")

  (setvar "clayer" la)

  (setvar "cmdecho" old_cmdecho)

  (princ)

)

 

 

Any help on either problem would be greatly appreciated.

 

Thanks!

Tags (3)
4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: Anonymous


@blitschmichael wrote:

.....  I ... need this block to align to the slope of the roof.  When ... inserted thru the short cut key it comes in at its original location? The code is as follows:

 

(defun c:qr (/ old_cmdecho)

....

  (command "insert" "horizontal QA RTS" pause 1 1 0)

....

)

 

Is there a way to get this to align to the slope of the roof...?

 

 

... with the hatch.  ... it would switch to the hatch layer and allow me to select the angle and then a single pick point.  Then switch back to the layer I was previously on.  I wanted it to allow me to select multiple areas ....

 

(defun c:pw (/ la old_cmdecho)

....

  (command "-layer" "S" "hatch" "")

  (command "-hatch" "Properties" "dolmit" 1 pause pause " ")

  (setvar "clayer" la)

....

)

....


On the first, I assume you mean it comes in at its original rotation.  It's the 0 that fixes that rotation angle.  The simplest thing would be to change that to pause and let the User select some Object-snap point on something like a roof-section Line, assuming that's how the insertion point was specified in the previous pause.  But it could be made more sophisticated, to extract the slope from a selected Line [or Polyline, or some other possibilities] and use that, so that the User doesn't need to specify.
 

On the second, I would suggest replacing your Hatch (command) line with the following, which should allow you to mess around inside the Hatch command as long as you need to, using whatever options you choose, and only when you're done with it, change the Layer back:

 

....

  (command "-hatch" "Properties" "dolmit" 1); stop there -- leaves you in Hatch command

  (while (> (getvar 'cmdactive) 0) (command pause)); User input until command is done

  (setvar "clayer" la)

....

 

You could also pre-set the pattern name and scale, and take them out of the command itself:

 

....

  (setvar 'hpname "dolmit")

  (setvar 'hpscale 1)

  (command "-hatch")

  (while (> (getvar 'cmdactive) 0) (command pause)); User input until command is done

  (setvar "clayer" la)

....

Kent Cooper, AIA
Message 3 of 5
Anonymous
in reply to: Kent1Cooper

Kent thanks for the help the first problem is solved with such a simple solution...

 

I've taken your advice and removed the properties out of the command line but I have a few hatch patterns that have different angles in them.  One I rotate the hatch 45 degrees and the other being the plywood hatch I rotate between various angles depending on the location of the plywood.  I tried to use the following for them:

 

(setvar 'hpang 45) ;for the one

(setvar 'hpang pause) ;for the plywood so I can enter the correct angle

 

The 45 degree angle will place it at 53 when inserted and the pause just returns an error? 

Message 4 of 5
Kent1Cooper
in reply to: Anonymous


@blitschmichael wrote:

... I have a few hatch patterns that have different angles in them.  One I rotate the hatch 45 degrees and the other being the plywood hatch I rotate between various angles depending on the location of the plywood.  I tried to use the following for them:

 

(setvar 'hpang 45) ;for the one

(setvar 'hpang pause) ;for the plywood so I can enter the correct angle

 

The 45 degree angle will place it at 53 when inserted and the pause just returns an error? 


If you're setting the angle directly into the HPANG System Variable, it needs to be in radians:

 

(setvar 'hpang (/ pi 4))

 

will put it at 45 degrees.

 

If you're asking the User for it, it should be done this way:

 

(setvar 'hpang (getangle "\nHatch rotation angle: "))

 

That will let them enter it either by typing, in current angular units [so in this case they would use degrees if those are your usual setting], or by picking the angle between points on-screen; either way, it will return it in radians.  [The 'pause' thingie only works inside a (command) function, not in (setvar).]

Kent Cooper, AIA
Message 5 of 5
Anonymous
in reply to: Kent1Cooper

Kent,

 

Thanks for your help and suggestions.  Just removing the proprites out of the command line seams to have helped clean things up from a running prospective.  Being new to the programing side it is great to find people that are so willing to take the time to help with such simple problems.  Thanks again!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost