×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Color assignment by object type5

 Forum Search FAQs Links MVPs

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

### RE: Color assignment by object type

Yes... just make sure that you plot by line weight, and, not colour or assign your colours to an appropriate line weight.

Dik

### RE: Color assignment by object type

(OP)
This doesn't have anything to do with plotting, it's strictly a geometry type issue.

### RE: Color assignment by object type

why not to create a layer with the color you want only for curves to be modified ?

### RE: Color assignment by object type

(OP)
The whole point is, I want ALL splines to be modified, and I want them to initially open the DXF file with the splines a specific color. It's not as simple as creating a layer.

### RE: Color assignment by object type

#### Quote (RobyengIT)

This doesn't have anything to do with plotting, it's strictly a geometry type issue.

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

(OP)
I didn't realize my original post was so difficult to understand. This has nothing to do with line widths or linetypes.

"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

You will need to write a custom routine (LISP or VBA) to automate this.

### RE: Color assignment by object type

OP: Colour may have a bearing if you ever want to print the CAD file.

Dik

### RE: Color assignment by object type

When exporting flat patterns from Inventor to DWG, there is ability from Flat Pattern DWG Export Options -> Geometry tab to replace Splines into other geometry.
In that way you will get the clear flat pattern without any Splines.

### RE: Color assignment by object type

(OP)
I believe TerryScan is correct on this, in that it would require a custom routine. I just don't see how it would be possible any other way.
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

You can select all SPlines and change their color or layer using the keyboard. Once you have mastered this manually, create a short LISP routine that uses the same commands. Then you have to make it execute when AutoCAD opens a drawing, again should be easy.

### RE: Color assignment by object type

(OP)
Thank you guys, I appreciate the input! Currently, our models are done in Inventor, then the DXF files are processed or "cleaned-up" in AutoCAD. Splines don't occur terribly often, but as you mentioned SparWeb, it's when a bend crosses a radii. I am not particularly fond of replacing a spline with short line segments, and I usually just delete it and replace it with a clean radii in the flat-pattern. On the occasions when I design parts, I always strive to avoid this scenario. Unfortunately, It's a case of many designers, few draftsmen.

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

You can also directly edit the DXF file and change the color for SPlines.

### RE: Color assignment by object type

(OP)
Yes, that's exactly how it's handled now.

#### Quote:

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

### RE: Color assignment by object type

I meant editing the DXF file outside of AutoCAD (it is a pure ASCII text file and easily decoded), probably not in the cards this time...

### RE: Color assignment by object type

(OP)
Interesting idea, never really considered that, but I see how it would be possible.

### RE: Color assignment by object type

It could be helpful, to motivate the "many designers" to act more like the "few draughtsmen", if you could make sure that all calls from the shop when the DXF won't convert are routed to THEM not you.
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

(OP)
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

You're welcome!

STF

### RE: Color assignment by object type

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" "") 

### RE: Color assignment by object type

(OP)
Thank you maripali, I will give this a go!

### RE: Color assignment by object type

2
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" "")
)

(OP)
Excellent!!

### RE: Color assignment by object type

This is where defun begins!

(sorry)

STF

### RE: Color assignment by object type

(OP)
Lol, I see what you did there.

### RE: Color assignment by object type

SparWeb... was good...

Dik

### RE: Color assignment by object type

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

### RE: Color assignment by object type

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.

### RE: Color assignment by object type

(OP)
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! :)

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

#### Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!