Info box SameAs utility

Started by prl, December 07, 2006, 11:42:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

paulerens

Lar and JJG,

Très respecté. Highly respected.

Paul.

JJG

#16
I posted this way to activate the fingerinfobox because, since I found this trick to run it only in macro language, I use it in several of my personnal macros, especially thoses for copying specific properties, as do the 6 macros provided by Lar.

With the difference that Lar uses the classical procedure consisting in "Pointselect" followed by "GetSelection" , as I used also in the past (eg in the macro Hatch sameAs I posted here: http://forum.designcad.com/index.php?topic=2467.0  ), followed by "Query" and "Change" actions.

But as I already explained in another post (  http://forum.designcad.com/index.php?topic=2468.0  ), this procedure does not read well the properties of entities which are in groups, in improper solids, let alone in the symbols or blocks ...
The second drawback, in my point of view, is that the actions of "Query" and "Change" can not be undone simply by "Ctrl Z" ...


While fingerinbox, him, it succeeds every time (to read well the properties of entities in all circonstances) !
And its action can be undone simply by "Ctrl Z" ...
(is not it great?)

Consequently, soon (today is Sunday!), I will continue this topic stating how to integrate fingerinbox for such specific actions, because it is not always obvious, especially as the fingerinbox does not necessarily recognize every things directly ...

Lar

What started me off writing those macros was the fact that the same-as finger does not capture the fixed lineweight and setting it via the info box takes so much clicking and scrolling.

I've thought about writing some for text entities to get just the text size or just the font or just the angle (same sort of thing for hatch entities and dimensions) but that's about as far as I got on those projects. If basiccad allowed dialog boxes of some sort then I could write a single macro with options for what to change. Having to write separate macros and load them all into toolboxes, or set hot keys, discourages me from writing certain types macros. I don't like the 'anykey' approach because I find it quicker to use the built-in approach than to have to read too much stuff to find which key does what.

Lar

Dr PR

JJG,

My only concern with your method is that the command has been disabled as a default. I wonder why? Is there a hidden bug in it?

Editing the ini file without understanding why is was set the way it is seems to me to be risky.
DesignCAD user since 1987

JJG

#19
Dr PR,

since 6 months, I made these changes in files Dc3MaxCmd.ini and Custom.ini
and I use this macro at least 10 times a day, without any worry.

Peoples of technical service of Cogistem (french distributor of Designcad) that I have consulted to find out why some commands have been put in comment to disable them, don't known too the reason(s) why these commands have been disabled.

It is  to be noted that all these disabled commands are all commands that I would call "indirect", I mean, which only can be running from a box (toolbox or infobox) already opened in DesignCAD, and acting on something which is selected before. They are never commands directly accessible via the menus.

The only bug that can happen is that the command does not run because there would be nothing selected :
Hence the precautionary in the macro that I propose to verify that something is previously selected.

Lar

#20
JJG,

How would you get the sameas finger to change particular things, like only the color or only the layer? Also, can it change the fixed lineweight (since the regular finger dos not)?

Lar

JJG

#21
Lar,

I understand perfectly what you say (at the end of page n°1 of this topic), and I fully share your point of view.

I also want to thank you very much for your many macro contributions (here or on other websites), who have personally learned me a lot about the tricks of programing Basicad since a long time ago! (as well as I want to thank the other contributors, including PRL and of course the technical department of Cogistem)


The only thing I noticed about this procedure (consisting in "Pointselect" followed by "GetSelect") is that it 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, as I said previously.
This is linked solely to the recognition faculty of "Pointselect", which clearly was not designed to work in groups, in improper solids, etc...

Whereas fingerinfobox succeeds always !

That's what I note at many times.
Hence the idea of using the power of recognition of the fingerinfobox, then, if possible, use of traditional commands, other than "Change", to apply the settings you want (I repeat : if possible) so that one could void execute the action by one (or several) "Ctrl Z ", if necessary (eg if the "target" entity was not the good one to recover the desired parameters).

QuoteHow would you get the sameas finger to change paticular things, like only the color or only the layer? Also, can it change the fixed lineweight (since the regular finger dos not)?
Lar

So to do what you ask now on only one of the parameters (I see that you are now interested ... !), the idea is:
1) in hidden mode, create (on a blank layer), an entity of the same nature as those we want to change the settings, and select it
2) apply to this new entity the fingerinfobox command, then "getSelect" in order to retrieve only the desired setting ;
3) delete this new entity
4) selectprewious for reselect the initial selection
5) apply a desired setting, if possible with a classical command, for "undo" possibility.


Nicolas79

command enabled by default is "strange".

I need it changes the layer and it would be perfect for my work.

now, macro language is too hard for me

JJG

#23
below some code as examples, to illustrate what I explained in my posts before :

first 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.


JJG

#24
secondly a "Color SameAs" macro, for "Copy Entity Color" :
'Color SameAs.d3m
'JJG, feb. 2011

'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

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

If sys(80)<1 then goto ESC

sys(996) = 1 'Enhanced Esc Key Behavior

' ### 1) creat an entity which will become the model for color 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

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

sys(36)=0 'super silent mode off

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

getselect 1,j
entity j
GETATTR j, type ,select, laynum, group, red, green, blue, solid
sys(300)=red 'define entity color, Red value, as Current drawing color, Red value [0-255]
sys(301)=green 'idem for Green value [0-255]
sys(302)=blue 'idem for Blue value [0-255]
'note : could be done too with sys(300)= sys(290) , sys(301)= sys(291) and sys(302)= sys(292)
'instead of GETATTR ...

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

' ### 4) selectprevious for reselect the initial selection ###
>SelectPrevious
{
 }

' ### 5) apply the desired settings to the initial selection ###
>ApplyColor
{
 }
 
' note : unfortunatly, Apply color is not undoable ... as such as for the same action manually done in Designcad

FIN:
sys(242)=a 'restore initial setting of Select object when created statment
sys(3)=Lay 'restore initial setting of active layer
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.

ESC:
inf$="Please select something before runing the macro ... !"
message inf$
End.

JJG

and two other examples for "Linestyle SameAs" :

fisrt one on the same model of building :
'Linestyle SameAs.d3m
'JJG, feb. 2011

'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.

Lay=sys(3) 'Store current layer
Linetype=sys(4) 'Store current Linetype
Linescale=sys(5) 'Store current Linescale
Linewidht=sys(6) 'Store current Linewidht
a=sys(242) 'Store Select object when created statment [0=no, 1=yes]

If sys(80)<1 then goto ESC

sys(996) = 1 'Enhanced Esc Key Behavior

' ### 1) creat an entity which will become the model for color 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

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

sys(36)=0 'super silent mode off

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

getselect 1,j
entity j
GETATTR j, type ,select, laynum, group, red, green, blue, solid
lt=sys(91)
ltscale=sys(97)
lw=sys(98)

sys(4)= lt
sys(5)= ltscale
sys(6)= lw

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

' ### 4) selectprevious for reselect the initial selection ###
>SelectPrevious
{
  }

' ### 5) apply the desired settings to the initial selection ###
>ApplyLineStyle
{
  <ApplyLineType
  <ApplyLineScale
  <ApplyWidth
  }

' note : unfortunatly, Apply color is not undoable ...

FIN:
sys(242)=a 'restore initial setting of Select object when created statment
sys(3)=Lay 'restore initial setting of active layer
sys(4)=Linetype 'restore initial setting of current Linetype
sys(5)=Linescale 'restore initial setting of Linescale
sys(6)=Linewidht 'restore initial setting of Linewidht
End.

ESC:
inf$="Please select something before runing the macro ... !"
message inf$
End.


and second one more more simple, and having the advantage to be undoable, but ...  (I hope that DT will tell us more about it ...)
'Linestyle SameAs undoable.d3m
'JJG, feb. 2011

'macro using some commands found in Dc3MaxCmd.ini file, which are not in the Macrocmd.ini file.
'it is ID_LSTYLE_SAMEAS=10465 and ID_LSTYLE_APPLY=10464 
'( Dc3MaxCmd.ini and Macrocmd.ini files can be found ordinary in C:\Program Files\IMSIDesign\DesignCAD 3D Max 19 )
'The commands are usable in macro form:
'
'>ID_LSTYLE_SAMEAS
'{
'}
'
'and
'
'>ID_LSTYLE_APPLY
'{
'}
'
'note : although the job is very well done, and has the advantage of to be undoable with "Ctrl Z",
'Designcad deliver systematically an error message of executing command ID_LSTYLE_APPLY=10464  ...
'don't understand why ?


>ID_LSTYLE_SAMEAS
{
  }

>ID_LSTYLE_APPLY
{
  }

JJG

Finally, I think it would be really interresting to be able to access directly through the code to all finger_sameas of DesignCAD, which could greatly simplify the writing of many macros, and would also provide opportunities for Undo, if they exist, like when one uses the commands in DesignCAD manually.

JJG

Quote from: Lar on February 20, 2011, 11:42:44 AM
JJG,

How would you get the sameas finger to change paticular things, like only the color or only the layer? Also, can it change the fixed lineweight (since the regular finger dos not)?
Lar

Lar,

Of course, with this method I presented, it's not possible to do some changes (like the fixed lineweight) that the fingerinfobox does not ... Maybe there is another way ?

JJG

below a update of the above example of "Linestyle SameAs undoable.d3m" macro, with a trick to hide the unimportant error message, and some code to be efficient on entities who could have "Line Style by Layer" checked ...
'Linestyle SameAs undoable.d3m
'JJG, may 2011

'macro using some commands found in Dc3MaxCmd.ini file, which are not in the Macrocmd.ini file.
'it is ID_LSTYLE_SAMEAS=10465 and ID_LSTYLE_APPLY=10464  
'( Dc3MaxCmd.ini and Macrocmd.ini files can be found ordinary in C:\Program Files\IMSIDesign\DesignCAD 3D Max 19 )
'The commands are usable in macro form:
'
'>ID_LSTYLE_SAMEAS
'{
'}
'
'and
'
'>ID_LSTYLE_APPLY
'{
'}
'
' note 1) : LSTYLE APPLY is undoable ! ... as such as for the same action manually done in Designcad (just one "Ctrl z")
'
' note 2) : it's possible to precise the desired point in the ID_LSTYLE_SAMEAS, such as
'> ID_LSTYLE_SAMEAS
'{
'  <pointxyz [Ox, Oy, Oz]
'  }
'
'the current Line Type can be obtained from Sys(4), Line Scale from Sys(5), Line Width from Sys(6), and Fill status from Sys(24)

sys(996) = 1 'Enhanced Esc Key Behavior

Alias ENT_LINESTYLEBYLAYER  &H0118 'declaration

debut:
If sys(80)<1 then goto fin

'store the initial settings of line style
LT=sys(4)
LS=sys(5)
LW=sys(6)
FS=sys(24)

'precaution before doing LSTYLE APPLY = the entity do not have LineStyleByLayer checked
'and active layer does not use specific linestyle [sys(534)] and linewidth [sys(538)]

ELS=sys(534)   'store layer uses specific linestyle initial statment
ELW=sys(538)   'store layer uses fixed linewidth initial statment
ELSS=sys(542)   'store enforce layer linestyle settings on all new entities statment
sys(534)=0 'layer uses not specific linestyle
sys(538)=0 'layer uses not fixed linewidth
sys(542)=0 'do not enforce layer linestyle settings on all new entities

For j = 1 To Sys(9) 'Sys(9) is the number of entities

Entity j

if sys(96)=0 then goto nex 'if entity is not selected [0=not selected, 1=selected]
Change Ent_LineStyleByLayer, 0
update

nex:
next j

>ID_LSTYLE_SAMEAS
{
 }

sys(36)=2 'silent mode on, to hide unimportant error message

>ID_LSTYLE_APPLY
{
 }

'restore initial settings of line style
sys(4)=LT
sys(5)=LS
sys(6)=LW
sys(24)=FS
sys(534)=ELS
sys(538)=ELW
sys(542)=ELSS
sys(36)=0 'silent mode off

>regenerate
{
}

End

fin:
inf$="Please, select something previously ... ! "
message inf$
End

JJG

Similarly, it should also add a few lines of code to the other version ("Linestyle SameAs.d3m"), to restore all original settings as before the macro action, concerning the change of working layer (i. e. the parameters concerning LineStyleByLayer).
Here is the update :
'Copy Entity Linestyle.d3m
'JJG, feb. 2011

'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.

Lay=sys(3) 'Store current layer
Linetype=sys(4) 'Store current Linetype
Linescale=sys(5) 'Store current Linescale
Linewidht=sys(6) 'Store current Linewidht
a=sys(242) 'Store Select object when created statment [0=no, 1=yes]
ELC=sys(530)   'store layer uses specific color initial statment
ELS=sys(534)   'store layer uses specific linestyle initial statment
ELW=sys(538)   'store layer uses fixed linewidth initial statment
ELCS=sys(541)   'store enforce layer color settings on all new entities statment
ELSS=sys(542)   'store enforce layer linestyle settings on all new entities statment

If sys(80)<1 then goto ESC

sys(996) = 1 'Enhanced Esc Key Behavior

' ### 1) creat an entity which will become the model for color 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

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

sys(36)=0 'super silent mode off

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

getselect 1,j
entity j
GETATTR j, type ,select, laynum, group, red, green, blue, solid
lt=sys(91)
ltscale=sys(97)
lw=sys(98)

sys(4)= lt
sys(5)= ltscale
sys(6)= lw

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

' ### 4) selectprevious for reselect the initial selection ###
>SelectPrevious
{
 }

' ### 5) apply the desired settings to the initial selection ###
>ApplyLineStyle
{
 <ApplyLineType
 <ApplyLineScale
 <ApplyWidth
 }

' note : unfortunatly, ApplyLineStyle is not undoable ...

FIN:
sys(242)=a 'restore initial setting of Select object when created statment
sys(3)=Lay 'restore initial setting of active layer
sys(4)=Linetype 'restore initial setting of current Linetype
sys(5)=Linescale 'restore initial setting of Linescale
sys(6)=Linewidht 'restore initial setting of Linewidht
sys(530)=ELC
sys(534)=ELS
sys(538)=ELW
sys(541)=ELCS
sys(542)=ELSS

End

ESC:
inf$="Please select something before runing the macro ... !"
message inf$
End


I think, it is always important to try to refind the exact same settings in Designcad as it was before, when you have run a macro, : so, it avoids many careless mistakes.
This does not "cost" usually more than only a few extra lines of code to write the macro, and a few extra milliseconds to the execution ...