News:

Please note new Forum URL: forum.designcad.com

Main Menu
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.

Hatch SameAS macro

Started by JJG, January 13, 2010, 11:07:59 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

JJG

I would also recall that in Designcad V7 (and previous), there was the SameAs button in Hatch-command, what was very convenient ... (of course before to draw the hatch).

And more, in DC V7, when you opened Infobox for a hatch, and wanted to change the type of hatch, you could visualize other possibilities of hatch choices, what was very convenient too, and more more speedy than to try one to one the hatch possibilities in actual Infobox ; then just to click on the choosing one, and finished.

OK, quit now nostalgia.

For the first point (SameAs button), following in this develloper's of Cogistem advices (Cogistem = french distributor of Designcad), I developped for about 7 years ago the following macro, again to be able to use this feature very convenient :

' ##### SameaAs Hatch #####

set:
hatch_txt$= "Clic on a hatch"
setpoint hatch_txt$ 1
if sys(1) < 1 then goto set
pointval x1 y1 z1 1
>PointSelect
{
<Pointxyz [x1, y1, z1]
}

If sys(80)<>1 then goto fin
getselect 1,j
entity j
If sys(90)<>17 then goto fin
Dim x(sys(99))
Dim y(sys(99))

' ##### Reading of building points #####
for t=1 to sys(99)
pointval x(t) y(t) z t
next t

' ##### Name of hatch #####
nom$=sys$(1)

' ##### Scale of hatch #####
Echelle=sys(97)*Sys(32)

' ##### divers attributes #####
GETATTR j, type ,select, laynum, group, red, green, blue, solid

' ##### Calculation of angle #######

if (y(1)-y(sys(99))) <> 0 then
alpha=90-atan((x(1)-x(sys(99)))/(y(1)-y(sys(99))))
else
alpha=0
endif


>Hatch
{
<Color [red, green, blue]
<Layer [laynum]
<Scale [Echelle]
<Angle [alpha]
<Name [nom$]
}

sys(80)=0

fin:
End.


OK, work is generally done well, except sometimes in cases where the hatch we are clicking is in a group, or in a symbol, or in a bloc.
I think it's because of the approximate capability of method using PointSelect and Getselect instructions to recognize accurately all the possibilities of entities wich are under the point we set : just the most on the top is good recognized.
At the opposite, SameAs button of Infobox can all recognize with always good succes, and do its action on the specific entities ; but I don't known how to exploit his capabilities for doing this job ...

So, for anyone who would interrested with this Hatch SameAs macro !
Of course, give for this macro an icon, for better ease of use.  (if someone here could confirm me that to insert an image, the image sould be deposit previously on a server, or not ? , then I'll propose to you my icon)
Enjoy !

JJG

#1
to illustrate SameAs button of DC V7 : first attached image


The Infobox of DC V7 where you could visualize other possibilities of hatch choices : second attached image



And finaly the icon I create for runing Hatch SameAs macro :   

JJG


JJG

#3
below some code of the update of my "Hatch SameAs" macro, using the finger info-box :

'Hatch SameAs.d3m
'JJG, nov. 2010

'macro using a command specifically re-activated in Dc3MaxCmd.ini file, whereas it was disabled by being put in comment.
'it is ID_INFO_SAMEASBAR = 10673
'( Dc3MaxCmd.ini file conventionaly can be found in C:\Program Files\IMSIDesign\DesignCAD 3D Max 19 )
'So, to active the command again, the ";" before must be removed, then further in the file,
'a specific line C10673 = ID_INFO_SAMEASBAR must be created at the right place,
'that is to say in strict alphanumeric order ! (otherwise, the following commands in the list will be ignored)
'The command becomes usable in macro form:
'
'> ID_INFO_SAMEASBAR
'{
'}
'
'but one can also create a specific command name for it in the file custom.ini, eg "fingerinfobox";
'For this, simply add the line fingerinfobox = ID_INFO_SAMEASBAR to this file custom.ini
'restart the computer if DesignCAD has been launched before any changes to these files in the Windows session.

R=sys(300) 'Store current drawing color, Red value [0-255]
G=sys(301) 'Store current drawing color, Green value [0-255]
B=sys(302) 'Store current drawing color, Blue value [0-255]
Lay=sys(3) 'Store the active layer
SC=sys(530) 'Store Layer uses specific color statment(0/1)
LSC=sys(541)   'Store enforce layer color settings on all new entities statment

a=sys(242) 'Store Select object when created statment [0=no, 1=yes]

sys(996) = 1 'Enhanced Esc Key Behavior

' ### 1) creat an hacth entity which will become the model for settings ###
sys(36)=2 'super silent mode on
sys(242)=1   'Select object when created [0=no, 1=yes]
sys(3)=999 'draft layer

'set the draft layer to be sure the model will be have no enforced by layer settings
sys(530)=0 'Layer uses specific color (0/1)
'sys(534)=0 'Layer uses specific linestyle (0/1)
'sys(538)=0 'Layer uses fixed linewidth (0/1)
sys(541)=0 'enforce layer color settings on all new entities
'sys(542)=0 'enforce layer linestyle settings on all new entities

>Hatch
{
 <PointXYZ 0,0,0
 <PointXYZ 1,0,0
 <PointXYZ 1,1,0
 }

sys(36)=0 'super silent mode off

' ### 2) apply to this new hatch entity the fingerinfobox command, then getselect in order to retrieve only the desired settings ###
>fingerinfobox
{
 }

getselect 1,j
entity j
If sys(90)<>17 then goto Fin
Dim x(sys(99))
Dim y(sys(99))

' ######## Lecture des points de constructions ########
for t=1 to sys(99)
pointval x(t) y(t) z t
next t

' ######## Nom de la hachure ######
nom$=sys$(1)

' ######## Echelle de la hachure #####
Echelle=sys(97)*Sys(32)

' ######## attributs divers ##########
GETATTR j, type ,select, laynum, group, red, green, blue, solid

' ######## Calcul de l'angle #######

if (y(1)-y(sys(99))) <> 0 then
alpha=90-atan((x(1)-x(sys(99)))/(y(1)-y(sys(99))))
else
alpha=0
endif

' ### 3) delete this new hatch entity ###
>SelectDelete
{
 }

sys(242)=a 'restore initial setting of Select object when created statment
sys(3)=Lay 'restore initial setting of active layer
sys(530)=SC 'restore initial setting of Layer uses specific color statment(0/1)
sys(541)=LSC 'restore initial setting of enforce layer color settings on all new entities statment


>Hatch
{
<Color [red, green, blue]
<Scale [Echelle]
<Angle [alpha]
<Name [nom$]
}

sys(80)=0

Fin:
sys(300)=R 'restore initial setting of current drawing color, Red value [0-255]
sys(301)=G 'restore initial setting of current drawing color, Green value [0-255]
sys(302)=B 'restore initial setting of current drawing color, Blue value [0-255]
End.


It works now as well through groups, improper solids, symbols etc ... because using the power of recognising of the "fingerinfobox", which is much much better than the classical procedure (consisting in "Pointselect" followed by "GetSelect") , which does not recognize well the desired entity when this entity is part of a group, a improper solid, and worse yet, a symbol or a block.

JJG

read in  http://imsidesign.com/Products/DesignCADSeries/DesignCAD3DMAXVersion22/NewFeatures/tabid/1833/Default.aspx

this ability has been taken in account :


"Improved Hatch, Hatch Line, Hatch Fill :
A new "Same As" button in the Hatch dialog box allows you to easily match the style of the hatch being drawn to an existing hatch entity."

Great !