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.

Select object when created

Started by Pearco, April 22, 2015, 03:01:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pearco

Macro Experts:
I have a macro that will draw and insert a base cabinet tray in  a shop elevation drawing and I would like it to be selected when created for additional insert locations without having to run the macro again. As I have it now,it only selects the last object. I know I can turn it on and off manually, but I want the Macro to do it.
Any ideas?
Jim
User since ProDesign 1.5

prl

Jim, you want to insert it manually several times repeatedly, in essence pasting it here, there, etc?

I'll add some code to put it on the clipboard.  Where do you want the insertion point?

Pearco

prl;

The macro sets the insertion point at the Opening SetPoint command. It is the lower  left hand corner of the tray. The cabinet is already on the screen,so select all selects every thing. 

Jim
User since ProDesign 1.5

prl

Jim, looking over your code, you have several undefined variables.

leftstile
Toespace
Bottomrail
Trayheight

Your defining these somewhere before this routine?

Pearco

prl;

There are only two variables Trayheight and ArchHump whitch are hard coded in. The others are variables that help to define and draw the cabinet face frame. The procedure is as follows,
I first run the macro that creates the Base cabinet, then rum the tray macro. The ones you mention are a part of the base cab macro.
When I first wrote the tray macro, it was a part of the base cab macro. There was a if statement, shelves or trays.
I took it out to use else where, so it appears they are not needed now.
Jim
User since ProDesign 1.5

JJG

the way it is possible without using the clipboard :

' Base Trays
' 12-25-14
' by Jim

Initiallayer=sys(3) ' store active layer

' Set Info box out of the way

Sys(130) = 400
Sys(131) = 400

Input " Enter tray width ?", Width
Traywidth = Width

' Set up variables
' Sys(242) = 1 not necessary here

>Setstartpoint
{
}

TrayHeight= 2.5

ArchHump=.5

sys(3)=999 'draft layer


>Ortholine 'left side
{

<Pointxyz [x1+leftstile],[Y1+(Toespace+BottomRail)]
<Pointxyz [xi+Leftstile],[Y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Bottom
{
<pointxyz [x1+leftstile],[Y1+(Toespace+BottomRail)]
<pointxyz [x1+Traywidth],[Y1+(Toespace+BottomRail)]
}

>Ortholine 'Left side top
{
<pointxyz [x1+Leftstile],[Y1+(Toespace+Bottomrail+Trayheight)]
<pointxyz [x1+(Traywidth/3)],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Arc3 'Arc
{
<pointxyz [x1+Leftstile+(Traywidth/3)],[y1+((Toespace+Bottomrail)+(Trayheight))]
<Pointxyz [x1+Leftstile+(Traywidth/2)],[y1+((Toespace+Bottomrail)+(Trayheight-.5))]
<pointxyz [x1+Leftstile+((Traywidth/3)*2)],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Right side top
{
<pointxyz [x1+Leftstile+((Traywidth/3)*2)],[y1+(Toespace+Bottomrail+Trayheight)]
<pointxyz [x1+Leftstile+Traywidth],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Right side
{
<Pointxyz [x1+Traywidth],[Y1+(Toespace+Bottomrail+Trayheight)]
<Pointxyz [x1+Traywidth],[Y1+(Toespace+BottomRail)]
}

' Sys(242) = 0  not necessary here

>SelectLayer
{
  <Layer 999
  }
>groupDefine
{
  }

sys(3)=Initiallayer 'restore initial layer

>Applylayer
{
  }

End



Note it is possible to add a handle for copy, such as

>SetHandle
{
  <PointXYZ [Sx,Sy,Sz]
  <PointXYZ [Tx,Ty,Tz]
  <PointXYZ [Ux,Uy,Uz]
  }
after groupDefine-command.

;)

prl

#6
Quote from: Pearco on April 22, 2015, 11:24:17 AM
I took it out to use else where, so it appears they are not needed now.

Hmm, you are lucky BasicCAD doesn't initialize the variables to zero and you are at risk doing it your way. 

Regarding the multiple copies, if I were repeatedly pasting (inserting) a created part, in the macro after creating the part, I would select the part, set the handle where I want it and then copy it to the clipboard.  At that point you can paste as many copies as you want and the pasted copies will go where you insert them.  If this is what you are trying to achieve, let me know and I will amend your code.

Pearco

Thanks prl and JJG;

I ended up by moving the Traywidth variable to before the SetPoint command and looped the body of the macro with an if then statement and a goto if another tray is needed . Now I can insert many trays in the cabinet by only calling the macro once and setting the Setpoint where it is needed. If I continue trying to code different things, I may reach all the way up to rank of absolute beginner.

My only training in programming was old line basic, a dab of QB 4.5 and 1 semester of VB6. But I enjoy doing it.

Thanks again Guys.
Jim
User since ProDesign 1.5