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.

Increasing Pointmark Size - Matching Existing Colour

Started by aqua, February 07, 2008, 02:21:52 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

aqua

Designcad 13.13

Does anyone know the adjustments to the following code to ensure the new pointmarks it draws to replace each of the existing ones has the correct colour.

3D mode is to retain Z value of pointmark. Want to adjust pointmark size.

At the moment, it only ends up with red = 0, green or blue = 255

Regards Frank



'FTM-7/2/2008
'GPS pointmark enlarger only
Message "This function will switch to 3D mode (4 smaller screen views), adjust the GPS pointmark sizes, then switch back to 2D mode. Please wait for 2D mode (1 screen view) to return:"
'
OldMode = Sys(344)
If Sys(344) = 1 Then
   >2DMode
   {
   }
End If
OrgCount = Sys(9)
For i = OrgCount to 1 Step -1
    GetAttr i, type, select, layr, red, green, blue
    If (type = 70 and layr > 1 and layr < 41) or (type = 70 and layr = 102) or (type = 70 and layr = 103) Then
red$ = red
'Remove this message - for checking error only
message "red = ", red
green$ = green
blue$ = blue
        Gosub fixup
    End If
Next i
If Oldmode = 1 Then
>2DMode
   {
   }
end if

End


' Subroutine fixup
fixup:
Entity i
Pointval xc yc zc 1
Sys(1) = 0 ' clear points
Sys(80) = 0 ' clear selection (just in case)
PutAttr i, 70, 1 ' select the point mark, then erase it
>Erase
{
}
sys(3)=layr
'Second attempt to use the colors from original pointmark
sys(300) = red
sys(301) = green
sys(302) = blue

>PointMark
{
    <Color [Red$, Green$, Blue$]
    <Size [10]
    <Type 3
    <Pointxyz [xc, yc, zc]
}
Precision 0
Return

edgar

I am rusty in Basic, but...

Quote

>PointMark
{
    <Color [Red$, Green$, Blue$]


do the cap (i.e. Red) and/or the $ (i.e. Red$) not create a brandnew var which is not initialized? Is...

   <Color [red, green, blue]


What you need?
-Ed

aqua

Edgar

Found the problem. Needed to add group into the code.

    GetAttr i, type, select, layr, group, red, green, blue

Regards Frank

edgar

So, now I need to expose my forgetfulness (can't be ignorance, as I'm sure I once knew the answer)...

your:

GetAttr i, type, select, layr, red, green, blue
If ... Then red$ = red
...
<Color [Red$, Green$, Blue$]


would cause me fits! I assume that
GetAttr i, type, select, layr, red, green, blue
automatically declares a variable of type default called "red"; then
red$ = red
defines another different variable of type $ (string) with the identical name; then via a behind-the-scenes StringConvert assigns it the string for which the numeric value stands. Finally,
<Color [Red$, Green$, Blue$]
uses the red$ variable by a defacto alias of "Red$". Is this correct?
-Ed

Lar

Putting the $ makes it a text string rather than a numeric string. Not sure what the result would be in BasicCAD. If Frank got it to work I guess the data type was converted somehow, or the type did not matter.

Lar

aqua

Designcad 13.13

Edgar - I have over 1600 basiccad macros.
90 % of the time - i know what I'm doing, the other 20% - I haven't a clue.
I use 2 methods - one I call the sledgehammer approach - lots of code and hardwork to get the result.
The other is inspiration, mine or others - where good understanding or creative ideas get the results.
In some cases - I don't attempt method 1, and wait until the simple solution arrives one day.

In method one - if the code doesn't work, I just steal code from other macros and try different ideas.
If $ in the code works - it works - that's fine by me.
If I discover I don't need it - that's cool too.
Sometimes I will have code that does not work because $ is missing - even though I thought it wasn't required. I just go with the flow.

Regards Frank

Macro below - without the $

'FTM-9/2/2008
'GPS pointmark enlarger
Message "This function will switch to 3D mode (4 smaller screen views), adjust the GPS pointmark sizes, then switch back to 2D mode. Please wait for 2D mode (1 screen view) to return:"
'
for i = 1 to 40
layer(0+i)=6
next i

layer(102)=6
layer(103)=6

'
OldMode = Sys(344)
If Sys(344) = 1 Then
   >2DMode
   {
   }
End If
OrgCount = Sys(9)
For i = OrgCount to 1 Step -1
    GetAttr i, type, select, layr, group, red, green, blue
    If (type = 70 and layr > 1 and layr < 41) or (type = 70 and layr = 102) or (type = 70 and layr = 103) Then
        Gosub fixup
    End If
Next i
If Oldmode = 1 Then
>2DMode
   {
   }
end if
End


' Subroutine fixup
fixup:
Entity i
Pointval xc yc zc 1
Sys(1) = 0 ' clear points
Sys(80) = 0 ' clear selection (just in case)
PutAttr i, 70, 1 ' select the point mark, then erase it
>Erase
{
}
sys(3)=layr
>PointMark
{
   <Color [Red, Green, Blue]
    <Size [5]
    <Type 3
    <Pointxyz [xc, yc, zc]
}
Precision 0
Return