Author Topic: Block scaling  (Read 2551 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 184
Block scaling
« on: July 30, 2013, 10:20:39 AM »
Hi, can someone explain me why scaling block that have been mirror doesn't work well ?
Here is an example.  On the right, it's the original block, on the left, it's a mirror of the block on the right.

Code: [Select]
BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForWrite);
Matrix3d m3d;
m3d = Matrix3d.Scaling(4, br.Position);
br.TransformBy(m3d);
« Last Edit: July 30, 2013, 10:37:56 AM by latour_g »

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Block scaling
« Reply #1 on: July 30, 2013, 11:08:14 AM »
You'll need to show the part of your code with the error in it  :-D this part looks fine

latour_g

  • Newt
  • Posts: 184
Re: Block scaling
« Reply #2 on: July 30, 2013, 01:23:53 PM »
I would like to but it's really only that in my code ! (with of course the traditionnal using (Transaction ...) and dispose, commit after)

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Block scaling
« Reply #3 on: July 30, 2013, 02:34:29 PM »
I think mirror is implemented as a negative scale in one of the axes (check the axis scale values for the block reference).  Not sure about the transform process, but if it assumes applying a positive scale in all axes then any previous mirror will be nullified.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Block scaling
« Reply #4 on: July 30, 2013, 03:29:48 PM »
Have you tried using the BlockReference.ScaleFactors instead of using a transformation?
Revit 2019, AMEP 2019 64bit Win 10

latour_g

  • Newt
  • Posts: 184
Re: Block scaling
« Reply #5 on: July 30, 2013, 04:29:37 PM »
Thanks dgorsman, you are right !
Well sorry Will, I realize that my snippet code was not complete. 
It's
Code: [Select]
m3d = Matrix3d.Scaling(((lRatio) ? nScale * br.ScaleFactors.X: nDwgScale / br.ScaleFactors.X), br.Position);instead of
Code: [Select]
m3d = Matrix3d.Scaling(4, br.Position); 
I wanted to make it look more simple  :-P

So with that, everything is working fine now.  Thanks you guys !!

Code: [Select]
BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForWrite);
Matrix3d m3d;
double nScaleX = br.ScaleFactors.X;
if (nScaleX < 0) nScaleX = -nScaleX;
m3d = Matrix3d.Scaling(((lRatio) ? nScale * nScaleX : nDwgScale / nScaleX), br.Position);
br.TransformBy(m3d);

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Block scaling
« Reply #6 on: July 30, 2013, 05:44:40 PM »
:lmao: awesome