DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Materials, Textures and Lighting

Started by Garry K, December 10, 2012, 04:50:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Garry K

I am trying to see how far I can get using macros and or ole or a combination of both.
I have both Version 16 and 22 in 3D.
Since I am using a Borland compiler which is a bit frustrating when using OLE objects - I will try to do most of the work using basic cad where possible.

Can I set up lighting, materials and textures in code? Or do I need to set some of it up before the macro runs?

If I can turn on lighting and save the setting in DC that would be ok too.
Do I need to create the materials ahead of time or can I do that from within macro and or ole?

MarkX

#1
Have you checked the DC 17 Macro help file?

Off hand, it looks like *maybe* you might be able to apply materials and textures already existing in the drawing. That's actually better than I thought. But you'd probably need to define them in advance. Sometimes these functions turn out to be more promising than they really are.

Doesn't look like you can do anything except toggle the dialog for lights.

Good luck!
Mark

Edit: Here's the stuff that looks promising:

>ApplyMaterial

{

}

Applies the current material to the selected items. The current material index can be obtained from Sys(349), or the material name from Sys$(91).

Compatibility: All versions


ENT_MATERIAL ParameterQuery and Change Parameters

ENT_MATERIAL

Declaration: Alias ENT_MATERIAL &H0111

Arguments: One number (integer) representing the material's index in the material table

Accessibility: Query/Change

Purpose: This parameter allows you to query or change the entity's material property.

Query Usage:

Query Ent_Material, emat

where emat is a numeric variable

Change Usage:

Change Ent_Material, emat

where emat is a numeric variable or expression

Compatibility: Version 14 and higher


Sys 283 – Opaque Texture Maps (V. 17.2)
[0=off, 1=on]
If Opaque Texture Maps is off, the wirefram color blends with the colors of the texture map (like a photographic slide projected onto a colored screen). If it is off, the texture map hides the wireframe color of the shaded object, showing only the colors of the texture map.

348 - Number of material textures in drawing [read_only]

349 - Current material texture

350 - Current material color, Red value [0-255]

351 - Current material color, Green value [0-255]

352 - Current material color, Blue value [0-255




prl

Garry,

Not much around that I know of.  OLE will give you more.

Maybe they've added some properties and methods to the TLB that aren't published in the SDK.  In C++, create a DcMaterial instance and dot it (DcDoc.Material.????) and see what properties/methods are offered.  If you find something, hope it has been implemented. 

If you find gold, let us know.

Dr PR

Material storage and retrieval is a little strange.

The program has some predetermined materials. They are automatically available when the program opens.

Users can create and save materials. These are saved in individual files, and not in a materials library. To use these materials you must open each file. This is a real pain.

I have a better way to deal with materials. I have a single file that contains a bunch of cubes. Each cube is assigned one of my custom materials. To include my custom materials in a new file I first open the materials file, select the appropriate cubes, then copy and paste them into my new drawing. This adds my custom materials to the new drawing. I typically reserve a layer for material cubes. After my custom materials are assigned to new objects in the drawing the materials layer can be deleted. The new objects retain the custom materials.

It's too bad the program doesn't allow us to create a custom materials library that is opened when the program starts so we could have all of our custom materials available for all drawings.

Phil
DesignCAD user since 1987

DrollTroll

With OLE Automation, you should be able to set up the lights using the SetLightSource method of the Option object. If you just want to check them, use GetLightSource. These are older functions which predate the ability to cast shadows, so should work even in version 16.

Version 22 (and possibly 21 and 20 as well) contains a GetLightSourceInt method in the Option class, which returns a LightSource object whose properties you can examine or set (including shadow-casting details).

For setting up materials, use the Materials class to get a particular Material, then examine (and set) its properties. Version 16 onlhy contains fields for "classic" textures; version 22 contains additional fields for the new procedural textures.

Sorry, I don't have any sample code on hand for these.
25 years with DesignCAD

Garry K

Thanks everyone - Every little bit helps shed a bit of light.

I think for rendering I will user version 22 but not version 16.

22 allows you to set lighting as a default - which simplifies macros.
I think I'll do what I have to with ole before the macro is run - and then do as much as I can with the macro.

Again - thanks