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.

Create Enlargement of Section of the Drawing

Started by aqua, March 21, 2007, 03:57:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

Designcad 13

The macro below is used to create an enlargement of a section of the drawing.
It use to work fine - not it has problems.
It appears that it relates to not selecting the objects when using the section copy

Can anyone shed any light as to what settings in Designcad might result in this function now not working?
If I am to update the code to get it to work - does anyone have the suggested code?

The macro allows one to select a rectangular area on the drawing, then create an enlargement of this area off to one side. It draws a rectangle arounf the original area and the new enlargement - with an arrow linking the two.

Regards Frank







'FTM-15/4/2006
'Disable other functions
sys(470)=1
'Show macro code to identify error
sys(800)=1
'Identify existing layer
el = sys(3)
'Make layer 270 visible and editable
layer(270)=6
'Set Rubberband on and shape to Box
Sys(41)=2
' Set Rubberband color to blue, (stays this color until reset)
Sys(306)=0
Sys(307)=0
Sys(308)=255
' Prompt user to set points
START4:
setpoint "Set two points around data to select it, TOP LEFT & then BOTTOM RIGHT" 2
'Turn off rubber band box
sys(41)=0
'If esc pressed then restore settings, i.e. Change colour to green
If Sys(1) < 2 Then
Sys(306)=0
Sys(307)=255
Sys(308)=0
End
endif

' Get Point Values for both points the user just set
PointVal x1, y1, z1, 1
PointVal x2, y2, z2, 2

If x1 > x2 then
Message " You must set your first point in the TOP LEFT corner, then the second point in the BOTTOM RIGHT corner:"
GOTO START4
END IF

If Y2 > Y1 then
Message " You must set your first point in the TOP LEFT corner, then the second point in the BOTTOM RIGHT corner:"
GOTO START4
END IF

'Make sure no items selected
sys(80)=0
'Make layer 270 current
sys(3)=270
'Need to confirm if I want this box on layer 270
>2DBox
{

<Pointxyz [x1+((x2-x1)/1000), y1-((y1-y2)/1000), z1]
<Pointxyz [x2-((x2-x1)/1000), y2+((y1-y2)/1000), z2]
  }
' Select objects using those two points the user just set
'Issue - Macro use to select objects - now doesn't

'Extra code - to select objects on creation - does not seem to have effect
sys(242)=1
>SectionCopy
{
<Type 0
<Pointxyz [x1, y1, z1]
<Pointxyz [x2, y2, z2]
}
'Not sure why the need to undo this box - will need to confirm.i.e. do we need to draw it in the first place
'Undo box
>Undo
{
}
'Box with dashed green line - this box should stay in current position on plan
>2DBox
{
  <Color 0,255,0
  <LineStyle 2,20.0000,0.1000
<Pointxyz [x1+((x2-x1)/1000), y1-((y1-y2)/1000), z1]
<Pointxyz [x2-((x2-x1)/1000), y2+((y1-y2)/1000), z2]
  }

sys(3)=270
>Paste
{ 
<Pointxyz [x1, y2, z1]
<Type 1
  }
'Turn off select on create
sys(242)=0
x11 = 0
y11 = 0
x12 = 0
y12 = 0
z11 = 0
z12 = 0

x11 = sys(196)
y11 = sys(197)
x12 = sys(198)
y12 = sys(199)
z11 = sys(200)
z12 = sys(201)
zmaxoriginal = z11

Originallength = sqrt((x11-x12)*(x11-x12) + (y11-y12)*(y11-y12))

START:
'Change rubber band back to off & colour to green
Sys(41)=0
Sys(306)=0
Sys(307)=255
Sys(308)=0
sys(3)=el
'if escape is used, then next line ends macro
'Needed to disable this
'Issue from above - it should have selected something by this stage
'If Sys(80) < 1 Then End

>OrthoMode
{
  }
>SetHandle
{
<Pointxyz [x1, y2, z1]
<Pointxyz [x2, y2, z1]
'turn off select handle dialog box
sys(244)=1
   }
'Turn on select handle dialog box
sys(244)=0
'
'if escape is used, then next line ends macro
If Sys(80) < 1 Then
>OrthoMode
{
  }

End
endif

>SelectMove
{
'Uncheck the use original scale
<Type 0
  }

x11 = 0
y11 = 0
x12 = 0
y12 = 0
z11 = 0
z12 = 0

x11 = sys(196)
y11 = sys(197)
x12 = sys(198)
y12 = sys(199)
z11 = sys(200)
z12 = sys(201)

zmaxnew = z11
if zmaxnew = 0 then zmaxnew = 1
newlength = sqrt((x11-x12)*(x11-x12) + (y11-y12)*(y11-y12))

factor2 = 0
factor2 = zmaxoriginal/zmaxnew

'factor = newlength/originallength
'factor2 = originallength/newlength

>SelectScale
{
  <Scale [1,1,factor2]
}

sys(36)=1
If Sys(80) <> 0 Then ' if layer is NOT empty, do some stuff
for j = 1 to sys(80)
GetSelect j, k 'store the entity id of selected entity j in k
Entity k
    getattr k, type, select, layr, group, red, green, blue
if select = 1 then layr = 270
  putattr k, type, select, layr, group, red, green, blue
  next
>GroupDefine
{
  }
endif
sys(36)=0
'Unselect all data
Sys(80) = 0
>Regenerate
{
}

>OrthoMode
{
  }

el = sys(3)
ts=sys(12)

a=0
a=sys(120)
b=0
b=sys(121)
c=0
c=sys(122)
d=0
d=sys(123)

size$ = 0.010 * Sqrt((c-a)*(c-a) + (d-b)*(d-b))
size2 = size$
if size2 = 0 then size$ = 10
'
SetPoint "Set points for arrow, press enter to complete, repeat or press Esc to end: ", 1
If Sys(1) < 1 Then
Sys(3) = el
End
end if

'turn off dialog box
sys(244)=1
sys(12)=1
Pointval x1 y1 z1 1

sys(3)=270
>Arrow
{

  <PointXYZ [x1,y1,0]
  <Size [Size$]
  <Type 4
}
Sys(3) = el
sys(12)=ts
'turn on dialog box
sys(244)=0
endDr

DrollTroll

It works fine for me, Frank.

I'd suggest you start by putting an END statement into the macro right after the SectionCopy command, and see if you can manually paste the supposedly-selected entities into a new drawing.
25 years with DesignCAD