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.

Text angle

Started by GooPie, March 22, 2015, 08:29:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GooPie

This macro allows me to assign a 90 ° angle to all text entities in a drawing.
I would like it to be adapted to operate only with entities previously selected.

Thank you for your help

-----------------------------------------

Include "*\dcadalias.d3i"

FOR j = 1 TO SYS(9)

entity j

change t_angle 0

UPDATE

NEXT j

>RegenerateAll
{
  }

END

samdavo

Goopie
This is a similar macro - sent to me by DT once - called FlattenZ  (i.e. sets z = 0).

You get the choice of Flattening All, or Flattening just the selection.
I'm guessing you could adapt it to your situation
cheers
' FlattenZ.d3m -- solves problems in "2D" drawings where z NOT equal to 0.
' User picks whether it works on the entire drawing or only the selection.
' Note: Pays no attention to layer visibility or editability if you choose entire drawing.
' Update 04/26/2013 - Fixed some problems with "Flatten Selection Only" option.

Alias ENT_TYPE &H0101  'R   - i
Alias ENT_NPTS &H010D  'R   - i
Alias ENT_POINT &H010E  'R/W - i,f,f,f
Alias ENT_GROUPINDEX &H0115  'R/W - i
Alias ENT_SOLIDINDEX &H0116  'R/W - i

'Sys(800) = 2

Input "Flatten Selection Only (1) or Entire Drawing (0); Esc to cancel", ftype
If Sys(999) Then End
If ftype = 0 Then
  Gosub FlattenAll
  End
End If

If ftype = 1 Then
  Gosub FlattenSel
  End
End If

Message "Cancelled. You didn't enter 0 or 1."
End

FlattenAll:
nEnts = Sys(9)
For i = 1 To nEnts
  Entity i
  Query ENT_NPTS, nPts
  if nPts > 0 Then
    For j = 1 to nPts
      Query ENT_POINT j, x, y, z
      Change ENT_POINT j, x, y, 0
      Update i
    Next j
  End If
Next i
Regen
Message "Done"
Return

FlattenSel:
nSel = Sys(80)
For i = 1 To nSel
  GetSelect i, j 'GetSelect only obtains grid headers, not the associated grid lines'
  Entity j
  Query ENT_TYPE, tp
  If tp = 32 Then 'grid header'
    Query ENT_NPTS, nPts
    For k = j+1 to j+nPts
      n = k 'n is the entity id used by FlattenEntity sub'
      Gosub FlattenEntity
    Next k
  Else
    n = j
    Gosub FlattenEntity
  End If
Next i
Regen
Message "Done"
Return

'FlattenEntity subroutine
'inputs: n = entity id
FlattenEntity:
Entity n
Query ENT_NPTS, ePts
if ePts > 0 Then
  For p = 1 to ePts
    Query ENT_POINT, p, x, y, z
    Change ENT_POINT p, x, y, 0
    Update n
  Next p
End If
Return

GooPie

Thank you Samdavo.
I'll watch this macro in the coming days, I think this should help me to solve my problem.

DrollTroll

Look up Sys(80) and the GetSelect statement. Those should give you the necessary tools.
25 years with DesignCAD

prl

#4
Include "*\dcadalias.d3i"

maxsel = sys(80)

FOR j = 1 TO maxsel
  Getselect j, entid

  entity entid
  Query T_Angle, tangle
  tangle = 0

  Change T_angle tangle

  UPDATE

NEXT j

>RegenerateAll
{
  }

END

GooPie

OK, once again thank you all

DrollTroll

Also, a cautionary note about Sys(9) and Sys(80) -- if you are ever *deleting* objects from the entity set (or selection set), be sure to count DOWN, not up. Deleting item n changes the index of the next item to n instead of n+1, so you could easily run past the end of the list if counting up to the original count value.
25 years with DesignCAD