Author Topic: How to set Material Scale Units?  (Read 3060 times)

0 Members and 1 Guest are viewing this topic.

P_M

  • Guest
How to set Material Scale Units?
« on: November 15, 2010, 11:42:38 AM »
Guys,

I'm a noob here and it's my first post so be gentle with me!

I've managed to create a material to apply to a 3dsolid. The problem I have is that when I look at the material in AutoCAD's Materials palette the Scale units under 'Material Scaling & Tiling' is set to Fit To Gizmo. This means that if I'm applying my material to a floor and the image I'm using is a terracotta tile type one, then I get four massive tiles covering my whole floor object. If I set the Scale Units to Metres I get a much more sensible texture.

I can't find anything which will let me set the scale units to Metres through the API. I was expecting it to be a property of the Mapper as it has the UTiling and VTiling but no Scale Units.

Any help would be much appreciated.

Thanks

kaefer

  • Guest
Re: How to set Material Scale Units?
« Reply #1 on: November 16, 2010, 08:51:46 AM »
Guys,

I'm a noob here and it's my first post so be gentle with me!

I've managed to create a material to apply to a 3dsolid. The problem I have is that when I look at the material in AutoCAD's Materials palette the Scale units under 'Material Scaling & Tiling' is set to Fit To Gizmo. This means that if I'm applying my material to a floor and the image I'm using is a terracotta tile type one, then I get four massive tiles covering my whole floor object. If I set the Scale Units to Metres I get a much more sensible texture.

I can't find anything which will let me set the scale units to Metres through the API. I was expecting it to be a property of the Mapper as it has the UTiling and VTiling but no Scale Units.

Any help would be much appreciated.

Thanks

Hi P_M,

I think you were on the right track but by the looks of if, no scale property is exposed except via the transformation matrix. See if this helps you further along:
Code: [Select]
    let doc = acApp.DocumentManager.MdiActiveDocument
    let db = doc.Database
    let ed = doc.Editor

    let per = ed.GetEntity "\nSelect entity: "
    if per.Status = PromptStatus.OK then
        let pdr = ed.GetDouble "\nFactor to apply: "
        if pdr.Status = PromptStatus.OK then
            use tr = db.TransactionManager.StartTransaction()
            let ent = tr.GetObject(per.ObjectId, OpenMode.ForWrite) :?> Entity
            let mm = ent.MaterialMapper
            let mt = mm.Transform
            ent.MaterialMapper <-
                new Autodesk.AutoCAD.GraphicsInterface.Mapper(
                    mm.Projection,
                    mm.UTiling,
                    mm.VTiling,
                    mm.AutoTransform,
                    Matrix3d.Scaling(pdr.Value, new Point3d()) * mt )
            tr.Commit()


P_M

  • Guest
Re: How to set Material Scale Units?
« Reply #2 on: November 17, 2010, 04:39:49 AM »
Hi kaefer

Awesome, thanks, the scaling is what I needed. I've been going round in circles for hours on this one!
It took a bit of fiddling with the scale factor but I got there in the end.
What language is the code you posted? Is it Lisp? Not a problem, just curious.

I'm doing the scaling as I set up the mapper for the material so it's a little different to the code you posted but you difinitely helped me out:
Code: [Select]
Dim Factor As Double = 0.001
Dim mapper1 As Mapper = New Mapper(Autodesk.AutoCAD.GraphicsInterface.Projection.InheritProjection, Tiling.Tile, AutoTransform.TransformObject, Matrix3d.Scaling(Factor, New Point3d()))

Thanks again.

P