Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color assignment by object type 5

Status
Not open for further replies.

blades741

Mechanical
Aug 1, 2012
47
Is it possible to assign a color to an object type? More specifically, I want to assign RED (for example) to SPLINES, and I want it done automatically (globally). The reason for this is simple: when we export sheet metal flat-patterns out of an Inventor drawing, we import it into AutoCAD for clean-up, which includes replacing all SPLINES with other geometry (our laser doesn't like splines). I want to incorporate this into a template, so when a DXF file is opened, the splines will automatically show up in RED. Currently, we select all and change it in the Properties dialogue box. This works ok, but I'd like to automate this if possible.
Thanks!
- Bill
 
Replies continue below

Recommended for you

The draftsmen are responsible for the DXF creation from the model, so hence the clean-up is our responsibility, of which splines are occasionally a part of. It's true that there are only a very few mouse clicks after opening the geometry, to identify the splines via. color change. My goal was some type of AutoCAD default setting (within a template, I presumed) that would have automatically identified the splines in red.

Depending on the length or effective radius of the spline, I usually replace it with a best-fit size radius. For that reason, I like to address each one individually, and need the color to easily identify it. As stated previously, I don't want them blanket-replaced with short line segments. The laser does much better with 'clean' geometry.

And then it occurred to me when reading your reply: I think I'm looking at this all wrong. I'm attempting to dumb-it-down for the other draftsmen. I think the REAL issue here is having them up their game, and be more diligent in identifying and replacing the splines to begin with, even if the initial identification of the splines is done manually. Thanks STF, I believe I see this issue much more clearly now. :)

- Bill

 
Now I understand your requirements to the DXF/DWG files.
Try these two lines in your Lisp code:
Code:
(setq AllSplines (ssget "X"  '((0 . "SPLINE")))) 
(command "CHPROP" AllSplines "" "C" "RED" "")
 
To make it work automatically, find your Acad.lsp file and add this:
(DEFUN S::Startup ()
(setq AllSplines (ssget "X" '((0 . "SPLINE"))))
(command "CHPROP" AllSplines "" "C" "RED" "")
)
 
Plagiarized it from a Autodesk poster in my college drafting teacher's office. This is back when Autodesk was a "big player" in CAD.

IIRC, the poster included a LISP program, that would draw a smiley face if you tried to use it.

STF
 
I have dozens of little LISP goodies in my Acad.lsp file that make my 2D and 3D live so much easier. Many are 1 or 2 letter replacements for standard commands some are long strings of commands for repetitive tasks, some do things Autocad does not.
 
I only mildly dabbled in lisp, never actually programmed anything myself. But I did appreciate the value of good lisp routines, and had a decent library of them. I was always big into custom menus & pgp file customization for quick command access. That was back in AutoCAD 12 days.

Funny story, back in the days of AutoCAD 12 I was quite a power user, and everything was customized. In spite of the stability of 12, it used to inexplicably crash and fully shut-down AutoCAD on the spot when I was in the middle of a command. No warnings, nothing. Gone. Then one day I finally found the bug: my right-click osnap menu was customized with shortened 3-letter snap points, and endpoint was simply END (this made it visually easier to find & select). That was all well and good, until I mis-clicked and didn't get myself into a command that was expecting an osnap input, and END meant just that! Hoisted by my own petard.

Anyway... can I just copy & paste this into the bottom of my acaddoc.lsp file as-is, or do I need to do some other magic with the parenthesis?

(DEFUN S::Startup ()
(setq AllSplines (ssget "X" '((0 . "SPLINE"))))
(command "CHPROP" AllSplines "" "C" "RED" "")
)

(credit to maripali & IFRs for the above)

Happy Friday! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor