Color assignment by object type
Color assignment by object type
(OP)
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
Thanks!
- Bill





RE: Color assignment by object type
Dik
RE: Color assignment by object type
RE: Color assignment by object type
RE: Color assignment by object type
RE: Color assignment by object type
You can make them any colour you like... often CAD programs use different colours for different line widths. Just check...
Dik
RE: Color assignment by object type
"I want to incorporate this into a template, so when a DXF file is opened, the splines will automatically show up in RED"
RE: Color assignment by object type
RE: Color assignment by object type
Dik
RE: Color assignment by object type
In that way you will get the clear flat pattern without any Splines.
RE: Color assignment by object type
Maripali: Interestingly, I did stumble onto this yesterday. I had always exported from the Inventor drawing, but I did find the setting you mentioned at the model (Flat Pattern) level. Unfortunately, I don't think this is an option for us, as replacing splines with short line segments would essentially create a speed-bump for our old lasers.
RE: Color assignment by object type
Flat Pattern DWG Export Options appears only on saving Flat Pattern as DWG.
There after generated Flat Pattern you should see the icon of the Flat Pattern at the bottom of the Sheet part Browser Bar.
With the right mouse button click on that icon drop menu opens with Save As... command.
Before saving select DWG format and change file name according to your requirements and save.
Immediately opens Flat Pattern DWG Export Options dialog box where you able to make some changes to the DWG file format and options.
If you tick on Replace Splines and Merge Profiles to Polyline, all spline curves will be converted to Polylines.
Still no had problems with any laser or waterjet no matter how old are them.
RE: Color assignment by object type
How are the parts originally modeled - in Autocad or Inventor?
If they start their life in AutoCAD then a few changes to the workflow of your designers might save you these headaches.
If you are making parts in Inventor, flattening them, and then exporting the pattern, then I've noticed a few things that help avoid getting splines in the DXF.
Primarily, keep fillets and corner radii from overlapping bend radii. This isn't always possible, but sometimes it can be a trivial change to the part to fix the overlap by changing the size of the radius or shifting the point of intersection slightly. If you use cuts, then radii on the cuts can also cause a spline if the cut intersects the part at an angle other than perpendicular. This would happen if the cut is placed on a face, but part of the cut extends over a bend (when the designer's intent is for the cut to have been done before bending, but places the cut feature after the bend features. Again, a workflow issue.
STF
RE: Color assignment by object type
RE: Color assignment by object type
Our current workflow is as you mentioned IFRs, done manually on the keyboard (select all, then select any splines from the Properties dialog box, and change color).
To be honest, I want this functionality for a small handful of others in our group who abhor any sort of change, and wouldn't employ any sort of LISP routine if it had to be launched manually. Worst case of "but we've always done it this way" I've ever encountered in my 40 year career. Small town in rural Indiana.
RE: Color assignment by object type
RE: Color assignment by object type
RE: Color assignment by object type
RE: Color assignment by object type
RE: Color assignment by object type
Pipe dream?
I have similar problems.
There's something I'd like to clarify, about the colors. It may be a red-herring that's been leading your other respondents in multiple directions.
If your stated problem is the presence of SPLINES in a DXF flat pattern which should instead be a closed POLYLINE, then what's the color for?
At the moment you have the DXF open in AutoCAD, and have the lines selected, and have filtered the selection to include only splines, which as far as I can tell requires only 5 clicks and possibly the pressing of the "a" key on the keyboard... at that moment, aren't you on the precipice of a choice between changing the color of the splines, or, pressing the DEL key on the keyboard and making them immediately go away?
Since you have to replace them anyway... why don't you do it at that moment?
STF
RE: Color assignment by object type
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
RE: Color assignment by object type
STF
RE: Color assignment by object type
Try these two lines in your Lisp code:
CODE -->
RE: Color assignment by object type
RE: Color assignment by object type
(DEFUN S::Startup ()
(setq AllSplines (ssget "X" '((0 . "SPLINE"))))
(command "CHPROP" AllSplines "" "C" "RED" "")
)
RE: Color assignment by object type
RE: Color assignment by object type
(sorry)
STF
RE: Color assignment by object type
RE: Color assignment by object type
Dik
RE: Color assignment by object type
IIRC, the poster included a LISP program, that would draw a smiley face if you tried to use it.
STF
RE: Color assignment by object type
RE: Color assignment by object type
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! :)