Functional Lisp - Just trying to simplify

Functional Lisp - Just trying to simplify

christian_paulsen98V29
Enthusiast Enthusiast
1,664 Views
23 Replies
Message 1 of 24

Functional Lisp - Just trying to simplify

christian_paulsen98V29
Enthusiast
Enthusiast

I made a lisp that allows me to assign a hatch to the face of a 3d solid. The only issue is that i have to select the face twice. Is there any way that i can just select the face one time? So that i can just have two total clicks. One to isolate the object, one to select which face to hatch.

;QUICK COMMAND TO CREATE A HATCH IN MODEL
(Defun c:MODELHATCH ()

(setvar "CMDECHO" 0)

(prompt "\nMODEL HATCH - Select object to hatch ..")
(setq SS1 (ssget))
(command "isolateobjects" SS1 "")
(prompt "\nMODEL HATCH - Select face of object to hatch ..")
(command "ucs" "f" pause "")
(command "-hatch" "p" "stars" "1" "0" pause "")
(command "unisolateobjects")

(setvar "CMDECHO" 1)
)

;how can i make it to where i select the face one time instead of twice
0 Likes
Accepted solutions (1)
1,665 Views
23 Replies
Replies (23)
Message 21 of 24

christian_paulsen98V29
Enthusiast
Enthusiast

Here are my takes on all of the lisp routines you provided.

Joinlsp-
Works as it should. I don't understand the difference between this command and the native "join" command. Could you perhaps explain why this one might be better? Although I'm all about customization when necessary, i try to to use native AutoCAD commands as often as possible. No point trying to reinvent the wheel.

Modelhatch-
This one also works as it should. However I liked my version more for a few reasons. The first being that i can use a big selection box to select my objects, instead of having to click right on a thin little line of the object. The second being that i can just click anywhere on the face of the object to hatch it, instead of having to wiggle my mouse around a bit to get the blue circle for the face snap to appear. And lastly, my command was very specific to one particular problem I've been having at work so i needed the pattern, scale, and rotation to be specific every time. The option to input them is very cool, i just don't have any use for it at the moment. Also i think its hard to input the name of your hatch pattern unless you have them all memorized. A dropdown with commonly used hatch patterns would be cool... So even though i don't have a particular use for this at the moment. I definitely will keep it around in case i ever need it.

Modelhatchall-
This one worked as well and was probably my favorite. Being able to hatch all faces of an object at once is neat. I would probably modify it so that i can use a selection box to select the object instead of clicking the line, as well as make a set pattern, scale, and rotation or perhaps some kind of dropdown. Other than that this one is perfect. I cant think of a specific use for it right now, but now that the option is available I'm sure ill find some way to incorporate it.

Regionhatch-
This one worked but i don't particularly understand its use case. You can already hatch regions natively with the hatch command. So this just does the same exact thing as using the hatch command, using the select object method, and then selecting a region. If there's something more to it can you please explain?

0 Likes
Message 22 of 24

marko_ribar
Advisor
Advisor

For "joinlsp.lsp" and why it's needed, look at this topic at theswamp.org...

Here is link (you must be logged to have access to download attachments) : https://www.theswamp.org/index.php?topic=55918.0 

For selection of objects you are right, but I don't see why would I change already working things as I don't have needs to use those routines in different ways...

For regionhatch, I guess that you meight be wrong... To hatch planar entities that are in 3D rotated in any direction, you have to align current UCS to match that particular plane where region lies in 3D space before you apply native command hatch... I coded for that situation as also to return UCS to previous position like nothing happened... The same can be the case with modelhatch and modelhatch-all... But, I must agree, further automation can be possible (to select perhaps many 3DSOLIDS, REGIONS and iterate through sel.set and apply hatchings just like it's already working with single entities)...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 23 of 24

marko_ribar
Advisor
Advisor

@christian_paulsen98V29 

According to your insights (remarks), I promptly updated (c:modelhatch-all) posted at previous page... Routine now expects that you select many 3DSOLID entities and it hatches planar areas that could be founded on those 3DSOLID entities... It's just slightly revisioned, but nevertheless I inform...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 24 of 24

christian_paulsen98V29
Enthusiast
Enthusiast

Just tested it. I like this version much more. 

0 Likes